Hello! I have this code right now:
mouse = psychopy.event.Mouse(
visible=True,
newPos=[3000,-500])
I want to randomize the starting position of the mouse each time. My first thought was to create a list of positions from where the code randomly chooses, but I am not sure how to approach this. I would appreciate any help. Thank you!
First create some list of positions and randomise it:
from psychopy import event
from numpy.random import shuffle
# initialise some list of possible starting values in whatever way you need:
starting_positions = [[3000, -500], [3000, 500], [-3000, -500], [-3000, 500]] * 2 # etc
# randomise it:
shuffle(starting_positions)
# create a mouse:
mouse = event.Mouse(visible = True)
Then whenever needed, grab an entry from that list:
mouse.setPos(starting_positions.pop())
Awesome! You made it so easy. Thank you so much.