psychopy.org | Reference | Downloads | Github

Preventing Repeats in Randomized Loop, Code

Hello,

I’m building a task with 6 condition blocks that I want to randomize in a loop. I am able to successfully randomize the conditions in a loop using a “conditions” file with all the possible blocks, then moving through them all. However, I need to be able to prevent some of the blocks from occurring after one another.

I have 4 types of animals that I’ll be presenting, with 6 unique files. It looks like this:

  1. Kittens (1)
  2. Kittens (2)
  3. Puppies
  4. Spiders
  5. Snakes (1)
  6. Snakes (2)

I need to be able to randomize these blocks without presenting kittens (1)/(2) or snakes (1)/(2) next to each other. Advice? Thanks.