Constraining pseudorandomisation to a maximum distance
Hi all,
I am programming a variation of the n-back task. I am presenting a string of 16 letters (using a loop with the variable, letter). 12 of the letters are unique and four are repeated.
In the 1-back condition, the repeated letters must be presented immediately after the first appearance of the letter.
In the 2-back condition, the repeated letters must be presented 2 letters after the first appearance of the letter.
In the 3-back condition, the repeated letters must be presented 3 letters after the first appearance of the letter.
I am hoping to randomise the order of the presentation of the letters but need to constrain the presentation of the repeated letters.
There is the constrain variable mindist function, which can set a minimum distance for the repeated letters. Is there an equivalent maxdist? If so, I can set mindist and maxdist to the same value.
If not, how can I ensure the presentation at the correct number of letters?
Attached is a picture of how my experiment currently looks (the letters are assigned in the set_stims_order inline scripts).
Thank you in advance for any help people can provide.
Kyran.

Comments
Hey,
I do not know about the maxdist function but just one question can the first presentation of a repeated letter happen successively, like:
ABCAB... (for the 3 back here for instance)?
Best,
Sylvain
Hi Sylvain,
Thank you for your response.
Yes, the different presentations can be intermixed as you have described.
Kyran.
Hello Kyran,
I think this should work.
Look at this example for the 3-back:
Also a script attached to show you how to populate your loops.
I hope it helps!
Sylvain
Sorry for getting back to you so late but thank you so much for doing that, Sylvain.
I will have a look now to see how it works for me.
Brilliant, that does precisely what I need it to.
Thank you very much for your efforts, I really appreciate it.