When the player leaves the field of view, the enemy moves to the last known position instead of giving up immediately:
MEMORY_DURATION =3.0# seconds# When player is visible:last_seen_x = player.xlast_seen_y = player.ymemory_timer = MEMORY_DURATION# When player is not visible:memory_timer -= dtif memory_timer >0: steer_toward(last_seen_x, last_seen_y) # Move to last known poselse: transition_to("PATROL") # Give up