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

I don't get the shortest path #32

Closed
gyril opened this issue Sep 3, 2014 · 4 comments
Closed

I don't get the shortest path #32

gyril opened this issue Sep 3, 2014 · 4 comments

Comments

@gyril
Copy link

gyril commented Sep 3, 2014

Here is my initial grid, startpoint, endpoint and astar path:
capture d ecran 2014-09-02 a 22 33 46

However, if I add an obstacle (4 blocks of the graph are turned to 0s), this is the path I get:
capture d ecran 2014-09-02 a 22 33 56

It is obviously a sub-optimal path (it shouldn't go all the way down before the obstacle), however A* is supposed to return the optimal path and I don't get how/why it fails there.

Tell me if you need more data.

@gyril
Copy link
Author

gyril commented Sep 3, 2014

Hm after toying with it, the number of nodes is constant, so it's most likely because of the weighting of the diagonal moves (making this issue a duplicate of #10)

@bgrins
Copy link
Owner

bgrins commented Sep 4, 2014

Are you using the diagonal heuristic? I think this might actually be due to missing documentation / not assuming diagonal heuristic with a diagonal grid. Can you try adding { heuristic: astar.heuristics.diagonal } as a final parameter to the search function?

@gyril
Copy link
Author

gyril commented Sep 5, 2014

I've edited your library now so I think I broke things, but yeah, from what I understand, applying the diagonal heuristic would have worked; however, it is not documented and I expected it to be applied automatically when I chose a diagonal pathing.

@bgrins
Copy link
Owner

bgrins commented Dec 17, 2014

however, it is not documented and I expected it to be applied automatically when I chose a diagonal pathing.

Sorry about that, I've added a note to the README about the heuristic.

@bgrins bgrins closed this as completed Dec 17, 2014
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