[open] Random number addition and presentation
Hi there!
I'm starting to get desperate here, I think I tried everything to make this work, but I couldn't manage to find a solution for this.
I'm making an experiment, where I try to run a 10-cycles loop which presents a random number (randint(1,9)
) in every 2 seconds.
I want these random numbers to be added to each-other sequentially (there's an initial number at the beginning, which is 150), and if the participant loses track of the calculations, the result of the addition could be made present by simply pressing the space button. After this, the presentation and the addition of the random numbers would continue, and the showing of the result by pressing space could be repeated as many times as necessary.
The problem is that somehow OpenSesame doesn't remember the random numbers, or it adds too many random numbers at once, because, for instance, when the experiment shows 150 then 3 (at the very beginning of the sequence) and I push the space bar, the next thing that appears could be 164.
I'm at the point where I even define the OpenSesame experiment variables in inline code.
I have an inline code before the loop where I set the initial number (rand_add = 150
). Note, that I present this number before the loop.
In the GUI I don't define any variables anymore, just set the cycle count to 10 (also the presentation is sequential, not random). In the embedded sequence the random number (from 1 to 9) is always made shown except for when the space is pressed, and the result number is only shown when someone presses the space. In the sequence there's a keyboard response tool as well.
And then I have an inline code in the loop:
#this is the random number generator
rand = random.randint(1,9)
#this adds the appearing random numbers to the initial 150 in every cycle with a constantly increasing value
rand_add = rand_add + rand
#I figured that maybe by using convenience variables, OpenSesame would remember the number
#these set the variables for the experiment
exp.set('trial_rnumber', rand)
exp.set('trial_result', rand_add)
Can you tell me what's the real problem here? How can I make this work?
Thanks!
P.S. When I create a list element to collect the random numbers, at the end I only get back an empty list.
Comments
Hi,
From what I understand, your approach is correct. Set
rand_add
to some initial value before theloop
, and then increment it on every trial. But your question is a bit vague in what you want to do and how you have implemented this right now. Could perhaps upload the experiment somewhere, and explain in more detail what you'd like the experiment to do?Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!