PathFinding.js
PathFinding.js copied to clipboard
Limit number of operations
Hello,
I wonder if there is a simple way to tell this lib to stop once it has reached a certain number of operations. I have a game where some maps are labyrinths and I don't want to calculate a full path if I reach a certain distance/complexity (the destination is considered "too far" to be reached in one pathfinding pass).
Regarding the actual implementation, this would need to update each finder to include this new parameter. Or maybe I'm missing something?
It is possible, the implementation is quite trivial. I did this for the python implementation (see runs in keep_running that I call every time I iterate over the next node)
It would also be great to allow the limit to be set not by total number of operations/iterations but thrrough maximum distance. For example: a certain unit can only move 6 steps this turn so whenever an ongoing calculation reaches more than 6 steps, drop that path.
It might be possible to achieve that by passing a virtual "reachable this turn" grid instead of the full grid but that's pretty inelegant.
Bumping this old thread- this is something that would benefit me too.
I have units in my game which will attempt to generate a path to the player (but may often be blocked by other units)- so it never finds a path and hence, can become computationally expensive.