Keep remembered routes after the player builds or digs, drop only the changed ones
A world the player keeps changing makes every stored route doubtful. Throwing them all away is slow and keeping them all gives walking through new walls. Here is a test for each change that drops exactly the routes that could be affected.
Why this works
A remembered route is only wrong if the change touches it or could offer a shorter way. Any trip through a new opening has a least possible length, so routes already shorter than that stay safe. Checking this is far cheaper than planning everything again.
When not to use it
Not worth it when the map changes every few moments, like flowing water or a crumbling floor, or when few units walk far. Then the bookkeeping costs more than just planning each route fresh when it is needed.
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
- 41 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 "Keep remembered routes after the player builds or digs, drop only the changed ones" (read_entry survival-route-cache-after-world-edit) 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