Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to make diagonal paths less free? #39

Open
ghost opened this issue Mar 23, 2015 · 6 comments
Open

Any way to make diagonal paths less free? #39

ghost opened this issue Mar 23, 2015 · 6 comments

Comments

@ghost
Copy link

ghost commented Mar 23, 2015

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!

@bgrins
Copy link
Owner

bgrins commented Mar 23, 2015

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?

@ghost
Copy link
Author

ghost commented Mar 23, 2015

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.

@bgrins
Copy link
Owner

bgrins commented Mar 23, 2015

Sounds great, could you file a PR with your updated changes?

@ghost
Copy link
Author

ghost commented Mar 23, 2015

Sure, I'm at work now, but I'll submit one later today.

@ghost
Copy link
Author

ghost commented Mar 24, 2015

Okay pull request submitted.

@LukeWood
Copy link

was this ever fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants