astar-typescript
astar-typescript copied to clipboard
suboptimal path with diagonal and manhattan
i changed example to allow diagonal movement and experimented a little with it. seems like manhattan fails to find shortest solution under certain conditions. e.g. it produces this
instead of
(which is produced by other heuristics)
In Manhattan distance you only care about the distance in terms of horizontal and vertical movement, not about the number of nodes in between. So imho, the calculated solution is equally correct with the one you get from other heuristics or even this one:
Its always 4 horizontally and 5 vertically