I’ve been implementing an experiment in which the
Subject_position can be moved across a grid by pressing the arrows, which force the end of the routine and begins another one with a new
Subject_position. 10 seconds after the beginning of the experiment (or other conditions that are not worth mentioning here), a virtual predator appear in a corner of the grid. I did this by inserting in the “each_frame” of a code component the following code:
if if experiment_clock.getTime() >= 10: Predator_on = True predator_clock = core.Clock() else: Predator_on = False
and than, in the “Predator” component (a red triangle), I chose the “condition” option and
$Predator_on == True.
predator_clock in the exempt is because I needed that the predator started chasing the subject at a given velocity (e.g. 1 move every 3 seconds) starting 3 seconds after it appeared in the screen. I could give the predator the right directions by implementing a breadth first search algorithm and tried establish the chase start velocity by coding in a “every frame” tab of the code component the following:
if Predator_on == True and Subject_position != [-475, -225]: if predator_clock >= 3: Predator_position = list(reconstruct_path(came_from, start, goal)) predator_clock.reset()
The predator is moving to the correct position, but every new routine instead of in a predetermined velocity. I believe that’s because every new routine the code that make the predator_on is red again, but I can’t find a way of making this stop and start making the predator move under the control of the last code extract I copied. Also, the predator move immediately when the new routine begins, not waiting the 3 seconds I was planning.
Any idea of where is the problem? Or a solution? Please find the experiment attached if that helps.
@jderrfuss that knows the experiment a little?
Thanks in advance,