You could make an array that saves the player's last moves. So 0 would be stay, 1 up 2 right 3 down 4 left?