I’m also just now implementing a task-switching experiment and mostly rely on Builder.
Usually, it is dfficult to generate constrained randomization online, since you may run into a dead end (the next trial must be type X, but all trials of type X have already been used up). Therefore, I prepare csv files in R (quite brute force, actuially, simply generating an order and then testing whether the number of same and switch trials is the same and only keeping those).
Then I restrict my participant codes to be pp01…pp99 (actually probably pp40) and then use the number to read in a specific file in a code component in Builder, as below
So, with participant code being, e.g. “pp01” →
full_pp_name = expInfo['participant']
block1_dataSource = full_pp_name + "_b1.csv"
block2_dataSource = full_pp_name + "_b2.csv"
Then I use those variables as “conditions” file in the block settings (see image below).
Despite the red ink on that window, it works. It’s crucial to set the loop type to sequential then.
I am happy to share the R-code as well, feel free to contact me outside this forum (since this is not an R forum).