javascript-astar
javascript-astar copied to clipboard
Any way to make diagonal paths less free?
As far as I can tell, diagonal paths are free right now, meaning moving between walls whose corners touch is possible, like this: http://imgur.com/l8T5Dur
Is there any way to add in the option to disallow this behavior, preferably something as fancy as multiple options like this: http://pathfindingjs.readthedocs.org/en/latest/user-guide/diagonal-movement/
I really like how lightweight and fast your project is!
Oh, good idea. That shouldn't be too hard to implement, since the diagonal option is already on the Graph, we would just need to modify the neighbors call to check isWall() on the relevant nodes before adding them to the neighbors list.
The options available in pathfindingjs seem reasonable. We would want to treat true
being passed into the diagonal option in a reasonable way to prevent breaking people who are already using it.
Here is one proposal:
diagonal: 0 (default value - never) | 1 (always) | 2 (if at most one) | 3 (if no obstacles)
And then convert true
into 1
to keep backwards compat.
What do you think about that idea?
Yeah, that seems great! I actually made that issue before looking at your code, and I found it eminently readable! I was able to make the change in my local copy, but I added more options instead of extending the "diagonal" option (e.g., {diagonalFree: true}
, {diagonalAtMostOne: true}
, etc.). Your idea is better.
Sounds great, could you file a PR with your updated changes?
Sure, I'm at work now, but I'll submit one later today.
Okay pull request submitted.
was this ever fixed?