OK, in that case, we need to use code to keep track of what the value of a variable was n trials ago.
Insert a code component in your trial routine and put something like this in the
Begin routine tab (am assuming you loop is called
trials, and you will replace
your_variable with whatever is needed):
# keep track of the variable that was current two trials ago: if trials.thisN == 0: two_back = your_variable # initial value needed for trial 2 if trials.thisN == 1: one_back = your_variable # need this to swap with two-back on later trials if trials.thisN > 2: # need to update the n-back values two_back = one_back one_back = your_variable # set whatever keypress values are appropriate for this trial: if your_variable == two_back: correct_response = 'y' else: correct_response = 'n'
correct_response variable in your keyboard component to judge whether the right key as pressed.
You might need to skip the response collection on the first two trials (0 and 1). If so, put that stuff in a separate routine, and in a code component, put this in its
Begin routine tab:
if trials.thisN <2: continueRoutine = False