A fleeing enemy runs into a dead end instead of getting away
When a wounded enemy simply steps away from the player, it ends up pinned in a corner a moment later. Here is the trick that lets it pick a far, open escape even if the first steps lead sideways, and the one cell it must never cross.
Why this works
Stepping away from danger only looks at the next move, and every way out of a dead end seems to lead toward the threat. Giving far-off open places a pull that spreads along real routes lets the runner accept a bad first step for a good escape.
When not to use it
Skip it when the fleeing creature should be easy to corner, like a panicking civilian or a cornered animal in a hunting game. There, getting stuck is the fun. A simple step away from the player is also enough on open maps.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 53 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 "A fleeing enemy runs into a dead end instead of getting away" (read_entry flee-without-running-into-a-dead-end) 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