Plan a route over a river when the player carries only a few bridge planks
A river can be crossed by laying planks, but the bag holds only so many. A shorter path that spends more planks and a longer one that spends none are both valid. Here is how to search so the answer is right and never overspends.
Why this works
Arriving at a spot with planks to spare is not the same as arriving with none, because the first can still cross more water. So a route is not just where you stand but also what you have left, and the search must keep both in mind.
When not to use it
Skip it when planks are plentiful or can be picked up again, since a plain route over water is then enough. It is also the wrong tool when the river moves, freezes or floods, because the bridges you plan would not match the world.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 31 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 "Plan a route over a river when the player carries only a few bridge planks" (read_entry survival-limited-planks-bridge-route) 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