A* manhattan distance

17,102

Both paths have the same manhattan distance. Therefore, it is implementation dependant which path is chosen. To tell why this specific part was chosen, we would have to look at the code of this specific A* implementation.

Hint: Every path from a source to a target cell that uses only Von Neumann neighborhood(i.e., does not walk diagonally) and does not take a step into the "wrong" direction (i.e., never walks up or left in your example) has the same manhattan distance. So, if you are in New York, it doesn't matter which crossroads you take to reach a certain place in Manhattan :)

Share:
17,102
Zik
Author by

Zik

Updated on September 16, 2022

Comments

  • Zik
    Zik over 1 year

    I searched for the algorithm/pseudocode of A* I followed it and coded it. I used Manhattan distance for h(n). ( f(n) = g(n) + h(n) ) And this is the result,

    This always happen when there are no walls blocking the way, but when I put a lot of walls, it seems that it's taking the shortest path. Is this one the shortest path? I mean why is it not like this one below?

    This one is also A* Manhattan, and they have the same size (19x19). This is from http://qiao.github.com/PathFinding.js/visual/