IAT - I need help with randomizing stimuli

I can think of three approaches that could work here.

  1. Set up a fixed order of stimuli that meets the criteria. I don’t do this any more but you can definitely get AI help with the order creation.
  2. Set up the list of trials before the loop starts and then use a sequential loop. I demonstrate this method in my complex randomisation online demo.
  3. The easiest method would be to have a trial type counter and then end the trial early (i.e. skip) whenever the counter is greater than 3. However, you might need extra trials and end the loop after the appropriate number. Something like this in Begin Routine.
if Condition == oldCondition:
     trialCount += 1
     if trialCount >= 3:
          continueRoutine = False
     else:
          allCount += 1
else:
     trialCount = 1
     allCount += 1
if allCount == 50:
     trials.finished = True
oldCondition = Condition

The method for repeating skipped trials is called Repeat Subset on my online demos page.