Re:An aesthetically pleasing pathfinding visualizer
by _0ffh on Saturday November 05, 2022 @07:50PM
(#33487190)
Maybe it does only horizontal and vertical steps. In that case it makes no difference, because the heuristic should always give you the Manhattan distance, which is equal for all options that don't overshoot the goal.
[ Parent
| on HN ]
Re:An aesthetically pleasing pathfinding visualizer
by squeaky-clean on Saturday November 05, 2022 @07:57PM
(#33487231)
The blue squares show the nodes it checked, and with A star the entire map shouldn't be blue on an empty maze.
Re:An aesthetically pleasing pathfinding visualizer
by eknkc on Saturday November 05, 2022 @08:02PM
(#33487274)
Yeah _0ffh's point makes sense on the path found. But even if it finds a path that is basically one horizontal one vertical line, it should still check the immediate neighbors only.
Re:An aesthetically pleasing pathfinding visualizer
by _0ffh on Saturday November 05, 2022 @08:44PM
(#33487527)
Yeah right, in that case there's something wrong there! Maybe in the way it queues up the options.
Re:An aesthetically pleasing pathfinding visualizer
by squeaky-clean on Sunday November 06, 2022 @12:09AM
(#33488874)
Think I found it, if you change the sort in astar.ts to just return 1 or -1 based on the comparison it behaves like A-star.
untraversedTiles.sort((a, b) => {
if (heuristicCost[a.row][a.col] < heuristicCost[b.row][b.col]) {
return-1;
}
return 1;
});