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

Astar didn't found the shortest path, due to rounding errors. #1

Merged
merged 1 commit into from Oct 14, 2013

Conversation

Projects
None yet
2 participants
@PedersenThomas
Contributor

PedersenThomas commented Oct 10, 2013

The implementation of A* uses int variables for cost, but it at the same time supports diagonal lines, which mean that it doesn't allways find the shortest path.
If you for instance try with the following map, it doesn't find the shortest path.
sxxxooooxo
xoxxxxooxo
oxxoxoooxo
oooooxxxoo
oooxxooxxx
xxXooxxooo
oxxXxxoxoo
oxxoxooxoo
oxxoxooxox
oxoooxxxog

The patch changes the types to doubles, removes the floor calls, and fixes a problem in the function hueristic. The hueristic function should be "optimistic", understod as the hueristiccost should never be higher than the actual cost of getting to the goal.

@sethladd

This comment has been minimized.

Owner

sethladd commented Oct 14, 2013

Much appreciated!

sethladd added a commit that referenced this pull request Oct 14, 2013

Merge pull request #1 from PedersenThomas/master
Astar didn't found the shortest path, due to rounding errors.

@sethladd sethladd merged commit 3b9caf6 into sethladd:master Oct 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment