Spielerando

A compass points the long way round a world whose edges connect

When walking off the east side brings you back on the west, the nearest ore may lie behind you across the edge. Here is how to measure distance and direction in such a world, and which way to point when both ways are equally far.

Why this works

On a world whose edges connect, every pair of points can be reached two ways, and only the shorter one is the real distance. Looking at each axis separately and picking its shorter way gives the right distance and direction, since the axes do not affect each other.

When not to use it

Wrong for a world with real edges, such as an island with sea around it, where walking off the side is impossible. A plain straight difference is correct there, and folding would send the compass to places you cannot reach.

In the full entry

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

Say this to your AI

Use the Spielerando entry "A compass points the long way round a world whose edges connect" (read_entry survival-compass-on-a-wrapping-world) 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