Spielerando

Make units stop when they walk next to an enemy, but let them step away

A line of soldiers should block an enemy from running past it. The usual rule is easy to get half right: either units can slip by anyway, or a unit that starts next to an enemy is stuck forever. Here is the rule that does both jobs and what happens on the first step.

Why this works

A guard only blocks if passing by costs something. Ending the move on the first square beside an enemy makes a line of units a real wall, and ignoring the square where the move began means a unit already touching an enemy can still leave instead of being stuck.

When not to use it

Wrong for fast, loose games where units should dodge past each other, or for games with ranged fighters who do not need to stand close. There a blocking ring feels like a trap. A softer cost, such as slower movement near enemies, may fit better.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 18 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 stop when they walk next to an enemy, but let them step away" (read_entry zone-of-control-stop-rule) 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