Spielerando

Make units walk around walls without squeezing through the corners between them

Soldiers that slip diagonally between two touching walls look like ghosts, and paths that change every time you click look like a bug. Here is a route finder for a square map that goes around corners the way people expect and gives the same answer every time.

Why this works

A route finder that always follows the cheapest way will go through any gap it is allowed to. Banning a diagonal step unless both squares beside it are free closes the corner gap, and counting in whole numbers means equal routes compare equal, so the answer never changes between clicks.

When not to use it

Wrong for maps without a square grid, or for games where units move freely and smoothly, such as a shooter with open ground. There, route around obstacles with a mesh of walkable areas. On a huge map with thousands of units, it also gets slow.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 46 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 "Make units walk around walls without squeezing through the corners between them" (read_entry grid-pathfinding-no-corner-cutting) 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