Selected Algorithm: A*

  • Path
  • Wall
  • Start Cell
  • End Cell
  • Observed
  • Queued
  • Path

  • Left Clicking converts the hovered cell into a wall
  • Right Clicking converts the hovered cell into a path
  • Clicking and dragging also converts cells accordingly
  • S = Move the Start Node to the hovered cell
  • E = Move the End Node to the hovered cell
  • SPACE = start pathfinding
  • D = Toggle between adjacent and orthogonal movement
  • R = Clear search results
  • C = Clear the walls and search results

Graph traversal uses two lists: an open list (nodes to explore) and a closed list (nodes already explored). The open list starts with the start node. The algorithm repeatedly takes the next node from the open list, moves it to the closed list, and checks if it’s the goal. If so, the path can be reconstructed using parent references. Otherwise, its neighbors are added to the open list. If the open list becomes empty, no path exists.

The difference between algorithms lies in how the next node is chosen:

  • BFS: first-in, first-out (FIFO).
  • DFS: last-in, first-out (LIFO).
  • Greedy Best-First: chooses the node with the smallest estimated distance (h-cost) to the goal.
  • A*: chooses the node with the lowest total cost (f-cost = g-cost + h-cost), combining distance traveled and estimated distance to the goal.