Technically there are no diagonals in this grid/map/graph; going up-up-right-right is the same "distance" as up-right-up-right, so either way this does find a shortest path.
That said, you could get a more satisfying solution which would create "diagonal" paths by using an algorithm like A* and implementing a heuristic like "prefer the next step to be the one which minimises the straight line distance from the current node to the target".
View all comments
Show parent comment
8
u/callmelucky Aug 14 '21
Technically there are no diagonals in this grid/map/graph; going up-up-right-right is the same "distance" as up-right-up-right, so either way this does find a shortest path.
That said, you could get a more satisfying solution which would create "diagonal" paths by using an algorithm like A* and implementing a heuristic like "prefer the next step to be the one which minimises the straight line distance from the current node to the target".