OK, I’ve got something in mind, but it’s a different way of running loops that you’re used to:
- You’d need to construct a conditions array via programming code, based on the different orders you’d like to have.
- When you loop over it, you won’t be able to set stimulus parameters via
$someparameter
. Instead, it all has to be done via code.
If that’s OK, this is the approach. We use this experiment as a template: Thomas Pronk / demo_dynamic_loops · GitLab
Note that in this template, the second loop trials_2
doesn’t loop over a conditions file. Instead it sets up the stimulus_text using an array called stimuli
. This array is constructed earlier in the experiment (in the trials
loop). In your case, you can generate different values for stimuli
to meet your design. Since the design is rather complicated, I’d recommend doing that completely via code component.
Below is a code snippet that could get you started; Basically we throw a coin; based on head/tails you’ll have decimal or fraction first. Then another coin for addition vs multiplication. The third factor isn’t demonstrated, but it’s just an extension of the same idea.
Same principle you can use for addition/multiplication, equal/unequal denominator.
// Stimuli per cell
decimal_addition = ['da1', 'da2', 'da3'];
decimal_multiplication = ['dm1', 'dm2', 'dm3'];
fraction_addition = ['fa1', 'fa2', 'fa3'];
fraction_multiplication = ['fm1', 'fm2', 'fm3'];
if (Math.random() < 0.5) {
// decimal first
if (Math.random() < 0.5) {
// addition first
stimuli = decimal_addition.concat(decimal_multiplication).concat(fraction_addition).concat(fraction_multiplication);
} else {
// multiplication first
stimuli = decimal_multiplication.concat(decimal_addition).concat(fraction_multiplication).concat(fraction_addition);
}
} else {
if (Math.random() < 0.5) {
// addition first
stimuli = fraction_addition.concat(fraction_multiplication).concat(decimal_addition).concat(decimal_multiplication);
} else {
// multiplication first
stimuli = fraction_multiplication.concat(fraction_addition).concat(decimal_multiplication).concat(decimal_addition);
}
}
// Print to the terminal
console.log(stimuli);
Two final notes:
- However you turned, it will be a rather complicated algorithm, so test carefully
- You can easily try out the snipped above in the browser console. See this example: Thomas Pronk / tutorial_js_expose_psychojs · GitLab