Dear all,
I want to randomize the location of three text on the screen (textA, textB, textC) in three different positions. I also have a keyboard named Choice with allowed keys of ‘left’,‘down’, and ‘right’ to choose the text stimulus accordingly.
As Michael helped me, I use the following codes to shuffle the position of my text:
positions=[[0,-0.1],[-0.3,-0.1],[-0.6,-0.1]] shuffle(positions)
And in order to associate the key press with the randomized text, I used the following codes. I created a dictionary which maps keyboard responses to their corresponding x coordinate:
key_to_x = {‘1’:-0.6, ‘2’:-0.3, ‘3’:0}
Then store the x coordinate of each stimulus:
thisExp.addData(‘textA_x’, textA.pos[0])
thisExp.addData(‘textB_x’, textB.pos[0])
thisExp.addData(‘textC_x’, textC.pos[0])
And then indicate the x coordinate of the chosen stimulus:
thisExp.addData(‘chosen_x’, key_to_x[Choice.keys[0])
And this is what I got from the data file:
As you can see in the chosen_x column, the first element is a weird number that I don’t know how is it here! It is not all the story. the x coordinate of the chosen text is not exactly what I chose. For example, in the second row, I chose text B by pressing the ‘down’ button, but in the chosen_x column, I got the coordinate of text A.
I would appreciate any comments.