@Mirjam provides a general solution here:
In your specific case, something like this might work:
- Insert a code component on your trial routine (from the “Custom” component panel).
- In its “begin experiment” tab, put something like this ( we need to run this at the start of the experiment since the code is non-deterministic: we don’t know how long it will take to run (realistically though, it will be a fraction of a second for only 12 entries):
stimulus_list = ['v', 'b', 'n', 'm'] * 3
shuffle(stimulus_list)
# make sure the same target doesn't appear on consecutive trials
double_stim = False
list_ok = False
while list_ok == False:
for i in range(len(stimulus_list) - 1):
# check for equal neighbours:
if stimulus_list[i] == stimulus_list[i + 1]:
double_stim = True # D'oh!
break # can stop checking on this run
if double_stim == True:
shuffle(stimulus_list) # try a new order
double_stim = False
else:
list_ok = True # Yay! The loop won't run again.
print(stimulus_list)