Interleaving Loops

I have two routines (search_trial and probe_trial) that I need to interleave randomly. With the search trial appearing 70% of the time, and the probe trial appearing 30% of the time. Specifically, I want 336 search trials, and 144 probe trials.

Each routine loop has a conditions file that must be assigned to it, with a certain amount of possible trials. When interleaving these routines, I don’t want it to go through the entirety of the condition file. It has to randomly pick a row from the conditions for each routine.

How do I do this?

I’ve tried creating a master loop, with both routine loops inside of it, and a master conditions file specifiying trial type. I then created a code within the master loop but before both trials that looks like this:

searchNreps = (typeoftrial === ‘search’) ? 1 : 0;
probeNreps = (typeoftrial === ‘probe’) ? 1 : 0;

But it keeps saying “typeoftrial” is undefined. If anyone has any ideas, please let me know! I will link my experiment. Thank you!

master_trials.csv (3.2 KB)

homogeneous-probe2.psyexp (484.3 KB)

You use typeoftrial in search_trial but that routine also appears in search_practice_loop. Is it set in condition_file as well as in master_trials.

Also, you have routine_selector as a JS only code component. I would recommend that you change it to Auto and write the code in Python.