by yumario · 6y ago · 0 comments
Yep after playing around with it for a bit it didn't give a minimum path. I believe something is wrong with the heuristic you are using.
Edit: You can prove A* will give a min path as long as: heuristic(x to y) <= min_cost(x to y). Problem seems to be here https://github.com/ssaric/algoviz/blob/master/src/util/GridN... I think it should be a matter of removing "times 100"
I got my knowledge about heuristics from here:
http://theory.stanford.edu/~amitp/GameProgramming/Heuristics...
But in a problem where the algorithm can get stuck in dead-ends, it's possible to construct examples where the greedy heuristic is (much) slower than plain Manhattan distance. Here's an example:
xxx
xEx
x x
x x
x x
x x
Sxxxxxxxxxxxxxx x
x
xxxxxxxxxxxxxxxx