Randomising types of trials so the same stimuli do not repeat one after the other

I need a little clarification on what you’re trying to do. Is the idea that you want a random order, but you don’t want the same “voice” file to play twice in a row? So, for example, you never want one of the top four lines to be selected after another of the top four lines, but you do want the order to be otherwise fully random for 24 trials?

Also, a question I feel I should ask up front, are you planning to run this online on Pavlovia? If so, the solution will look nothing like what you have now. PsychoPy’s ability to convert Python code components to JavaScript can’t support importing external libraries like pandas.

If you’re just trying to run this locally on your computer, the easiest solution will be a nested loop structure in builder. You’ll need a trial to sit in between each cycle of 24, but it can even be a blank trial with the code component you currently have under “begin experiment” under “begin routine”. The outer loop repeats four times, and then you put another loop around the test trial itself that repeats 24 times.

If you want to do this online, that’s still probably going to be the general outline of the solution, but you’ll need to figure out some JS code that can do this.