Counterbalancing between two lists
in OpenSesame
Hello,
I want to present stimuli from two different lists (i. e. list a and list b) as mixed. They will come randomly but i want to add the condition that no more than 3 stimuli come from the same list sequentially. Indeed, participants will be presented 3 stimuli from one list (list a), and the next stimuli will be from other list (list b).
Would you help me to solve this problem, please?

Comments
Hi,
import random new_list = [] # for simplicity have the lists with 0s and 1s, you can later replace them with # the actual stimuli list_a = [0]*5 list_b = [1]*5 # while not all stimuli have been used while len(new_list) != 10: if len(new_list)>3: # only start checking once you have enough stimuli in list if sum(new_list[-3:]) == 3: new_list.append(list_a.pop(0)) elif sum(new_list[-3:]) == 0: new_list.append(list_b.pop(0)) else: # if not three in a row, choose a random list and select one from there new_list.append(random.choice([list_a,list_b]).pop(0)) else: new_list.append(random.choice([list_a,list_b]).pop(0))I haven't tested the code, but it should give you ideas, I hope. Let me know if you don't understand anything.
Eduard
Hi Eduard,
Thank you very much :)