astar-typescript icon indicating copy to clipboard operation
astar-typescript copied to clipboard

suboptimal path with diagonal and manhattan

Open caryoscelus opened this issue 1 year ago • 1 comments

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 manhattan instead of good (which is produced by other heuristics)

caryoscelus avatar Jan 24 '24 23:01 caryoscelus

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:

Image

Its always 4 horizontally and 5 vertically

MWFIAE avatar Mar 24 '25 09:03 MWFIAE