You might be able to adapt my Trial Switching demo. What I do is preload the stimuli and shuffle a list of 1s and 0s for each stimulus type which specify whether the next trial is a switch or not. In my demo I have letters and numbers which I think would correspond to your conditions 1 and 2 .