PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

Limit number of operations

Open Oza94 opened this issue 8 years ago • 3 comments

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?

Oza94 avatar Mar 04 '16 14:03 Oza94

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)

brean avatar Dec 29 '17 14:12 brean

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.

tukkek avatar Apr 09 '19 17:04 tukkek

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.

Bingdom avatar May 19 '23 04:05 Bingdom