Open byfron opened 4 years ago
Hello, I actually completely missed this issue for some reason.
Thank you for bringing this up, I don't exactly remember this code since this has been awhile, but you are correct that A* should be able to guarantee shortest path (and on this script it doesn't), since distance is admissible heuristic in this case. For the fix g(x) should probably be the cost from start to curr, instead of prev to curr.
First of all, nice piece of code! I found it very useful.
I noticed a small bug that makes the search behave like Dijkstra rather than A. In the demo image you can see that the path is not actually the shortest, while A is supposed to guarantee shortest path.
I believe that the cost needs to be computed as cost so far + heuristic cost to the goal .
The line
should instead represent the "true" cost accumulated in the current tile.
I hope it helps!