Hi. I am trying to design n-back test using builder view. I read the previous topics related to n-back and it was somehow unclear.

I created a routine and a loop (called trials) and in the condition file, below the “numbers” columns, I inserted numbers from 1 to 9. I selected the loop type as random.

I found the code below for dual n-back, but I only want one n-back (comparing a number only with the previous number).

```
# 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'
```

I would appreciate any comment on how I could rewrite this code for n-back test.