pathfinding
pathfinding copied to clipboard
Add support for computing an early abort for Astar based on cost
The problem im trying to solve is for astar calls that run forever. This typically happens when the target is unreachable (enclosed in walls, or on an unreachable tile, etc).
Bidirectional AStar would solve this, but another hacky way is to set a fallback limit on depth/steps for the astar search. An easy way would be to pass in the total cost as part of the success callback, so one could do something like |pos, cost| pos == target || cost > 500
.
Im curious on if there are better ways to solve this issue in general, I would love to hear any thoughts on this, although perhaps it is a bit out of scope of this crate!
If the parameter approach is interesting, id be happy to open a PR for this.