Random routines

OK, you need to insert a fourth loop, that surrounds all three of the existing loops. This outer loop will run three times, but on each iteration, only one of the inner loops will be allowed to run.

So:

  • Insert that fourth loop, set its nReps value to 3, and don’t connect it to a conditions file.
  • In the trial routine, insert a code component (from the “custom” component panel).
  • In the “Begin experiment” tab of that component, insert the following code, which will run once at the start of the experiment to randomise the order to be used for this session:
# specify which of the three inner loops will run on each of
# the three iterations of the outer loop:
orders = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

# randomise that order for this session:
shuffle(orders)

Now in each of the inner loops, you will want to replace the current fixed value of 1 for nReps to be a code expression which will evaluate to either 1 (the loop will run on this iteration) or 0 (this loop will not run):

  • trials loop:

      orders[0][outer_loop_name.thisN]
    
  • trials_2_reverse loop:

     orders[1][outer_loop_name.thisN]
    
  • trials_3 loop:

      orders[2][outer_loop_name.thisN]
    

i.e. orders is a list that contains 3 sub-lists, each with three entries. The trials loop will always look up the zeroth list within orders, and then look up the 1 or 0 value corresponding to the current iteration of the outer loop, and so on for the other two loops, so that only one loop runs on each iteration of the outer loop. This is why we use two indices, e.g. orders[0][2] is entry number 2 of the zeroth list within orders.

4 Likes