I am using builder to create my experiment which will be ran online. I am a bit new to python and don’t know much about coding. I am trying to counterbalance between 4 factors each with 2 levels which would lead to a total of 16 different combinations. I know that I can counterbalance this manually by setting up 16 different files and four different loops in order to do this. However, I am wondering if there may be a more convenient way to do this. Thank you in advance for your help!

Basically, I am trying to have my participants solve many maths problems. They will solve it in either blocked format or interleaved format. The factors I am trying to counterbalance are: condition(blocked vs. interleaved); number type(present fraction first vs. decimal first); operation(solve addition problem first vs. multiplication first); problem difficulty (hard first vs. easy first). Thank you for your help!

Sorry for my delayed response. I suppose Becca gave me a good starting point, but it is a bit different from what I intend to do.
Basically, I have 8 different lists of stimuli containing 9 items in each. There are 16 different orders for me to arrange the 8 lists. I am hoping to retrieve each element from the list randomly.
As previously mentioned, I have two conditions: blocked or interleaved. In the interleaved condition, I want to have elements from different lists presenting consecutively, I found it difficult to implement without coding.
One way to do it is to set up 16 different conditions, but it is not as satisfying because then each condition only contains one fixed random order.
Do you have any thought on how I can do this? Thank you very much for your help!

I’ll go figure out if I can write a little example experiment that demonstrates the structure you need. But first, more questions

You write: “retrieve each element from the list (of 16 orders) randomly”. That’s between-subjects right? If I got this right, might be tricky to randomize, but is counterbalancing an option two?

You’ve got two conditions (blocked or interleaved). Each of these conditions combines with each of the 16 orders, making 32 combinations?

Thank you so much for your help!
1.Yes, It is between-subject. I am trying to counterbalance 4 factors here, which leads to 16 different ordering of 8 lists. In order words, I have 16 different conditions participants can be assigned to. I suppose I could instead just set up 16 different conditions files but it would be less ideal than if I am able to set up the experiment such that for each participant in the same condition, they may solve the problems in different orders. I am not sure if I explained it properly, please let me know if it is confusing.
2. I have two conditions and 8 different orders within each condition, making 16 different combinations. Below is a graph of the 8 possible orders within each condition. I hope it makes sense. Within each unique number type x number feature x operation combination, there are 9 different problems. I am hoping that within each order, when each time a list is call upon, a problem is randomly selected.

Thanks, that’s very clear! Got one more question before I start fidgeting with code. It might be that the 8 orders within a condition are easily put into a single experiment, but the 2 conditions wouldn’t. If it would result in 2 experiments, one per conditions, would that work out for you?

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