Algorithm Map Drawing Pathfinding algorithms search a grid from S to G. Walls block movement; mud costs five times as much to cross. Draw walls or mud on the grid and run each algorithm.
- Compare BFS and A* on the open field: A* explores far fewer cells.
- Add mud: BFS goes through it, Dijkstra and A* go around.
- Greedy best-first is fast but can be fooled by a wall in front of the goal.
- Draw a wall right across the grid to see what happens with no path.
Four-directional moves. BFS uses step counts; Dijkstra and A* use cell costs (open 1, mud 5) with a binary heap; A* and greedy use the Manhattan distance, which never overestimates here, so A* stays optimal.