Make units walk around swamp and mud, but cross it when the detour is huge
Different ground should cost different effort, so roads get used and swamps get avoided. The catch is a shortcut in the search that quietly makes it return worse routes once the ground costs differ. Here is what to watch for.
Why this works
People do not avoid mud by rule, they weigh effort against distance. Giving every kind of ground a price, and letting the search find the cheapest total, produces that same trade-off without a single special case.
When not to use it
Skip it when the ground should simply be forbidden, like deep water or lava. Those belong as walls. Also skip it when every unit must take the shortest walk, such as in a puzzle with fixed moves.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 43 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 swamp and mud, but cross it when the detour is huge" (read_entry path-prefer-road-over-mud) 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