Hacker News new | ask | show | jobs
by squeaky-clean 1316 days ago
The blue squares show the nodes it checked, and with A star the entire map shouldn't be blue on an empty maze.
2 comments

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;
    });