Preventing Repeats in Randomized Loop


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.

I’m thinking something along the lines of shuffling A, A, A, A, Puppies, Spiders then replacing the first A with a random item from Kittens1, Kittens2, Snakes1 & Snakes2. Replace the second A with a random pick of the two versions of the other animal. Then go back to the first and finally the one remaining. This does limit kittens and snakes to alternating but it does mean you don’t get stuck being forced to show the same animal on the final two trials.

Please could you delete your identical post in coding? I can move this post to the coding section if you like.

Hi, it won’t let me delete the other message but I reported it and hopefully that will work, thanks.

1 Like