Spielerando

In a wrap-around arena the enemy flies the long way round to reach you

When the left edge of the screen leads to the right edge, a chaser at one side still races across the whole screen to a player who is just past the other edge. Here is how to find the short direction, and what to do at exactly half way.

Why this works

On a world where one edge leads to the other, every spot has copies one screen away, and the real distance is to the nearest copy. Working that out for each direction on its own gives the short way and the true distance at once.

When not to use it

Don't use it when the edge is a real wall or a place where the player can't follow, like a screen that only wraps for the player. A chaser that takes a shortcut the player cannot use will feel like cheating. Keep the plain direct route there.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 21 lines of example code with 4 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "In a wrap-around arena the enemy flies the long way round to reach you" (read_entry shortest-way-across-a-wrapping-screen) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP