Precision timing across multiple responses

Dear all,

I’m running an experiment in which a subject can move a blue circle throughout a 20 X 10 grid and, in a given moment, a predator appears and the subject will have to escape to a safe place before the predator captures them. When the chase begins, the Subject will have to move the circle 28 times until the safe place by using the following code:

if key_resp_arrows.keys == "right" and Subj_move_clock.getTime() >= 0.1:
    Subject_position[0] += Mov
    Subj_move_clock.reset()
elif key_resp_arrows.keys == "left" and Subj_move_clock.getTime() >= 0.1:
    Subject_position[0] -= Mov
    Subj_move_clock.reset()
elif key_resp_arrows.keys == "up" and Subj_move_clock.getTime() >= 0.1:
    Subject_position[1] += Mov
    Subj_move_clock.reset()
elif key_resp_arrows.keys == "down" and Subj_move_clock.getTime() >= 0.1:
    Subject_position[1] -= Mov
    Subj_move_clock.reset()

which means the subject’s max speed is 10 moves per second.

The predator will start chasing the subject 8 positions behind it and I was trying to make it “almost” capture the subject. My maths were that the subject would expend 2.8 secs to go through the 28 positions to get to the safe position so, the predator, in order to make the 28+8 positions (-3, not to really reach the subject) in the same 2.8 secs, would have to make one move every 0.085 secs. However, the predator is moving much faster than the subject.

I was wondering if this could be due to latencies added to each move for the subject, as each move is one keyboard keypress, that wouldn’t happen with the predator, which is commanded by the computer. Does that make sense? If so, how could I estimate this latencies, as well as other possible interferences and latencies, in order to adjust the Predator’s speed as a function of the Subject’s more precisely?

Thanks in advance.

Best regards,

Felipe

What’s the actual loop look like? When are you reading the key inputs? How is the timing for the predator controlled?