Hacker News new | ask | show | jobs
by _0ffh 1316 days ago
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.
1 comments

The blue squares show the nodes it checked, and with A star the entire map shouldn't be blue on an empty maze.
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.
Yeah right, in that case there's something wrong there! Maybe in the way it queues up the options.
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;
    });