The simulation currently implements and visualizes the following pathfinding algorithms:
- Breadth-First Search (BFS): Explores the maze layer by layer, guaranteeing the shortest path in terms of the number of steps.
- Depth-First Search (DFS): Explores as far as possible along each branch before backtracking. It does not guarantee the shortest path.
- Greedy Best-First Search: Uses a heuristic (Manhattan distance to the goal) to prioritize exploration. It's often fast but doesn't guarantee the shortest path.
- A Search (A-Star): Combines the cost from the start (g_score) and a heuristic (Manhattan distance to the goal, h_score) to find the shortest path efficiently. The heuristic must be admissible (never overestimate the true cost).
- Dijkstra's Algorithm: Explores based on the cumulative cost from the start node. Guarantees the shortest path in terms of cost (number of steps in this unweighted grid).
- Python 3.x
- NumPy
- Matplotlib
- Ensure you have a suitable backend for Matplotlib that supports interactive plots (e.g., Tkinter, which is often included with Python, or others like Qt5Agg).
These dependencies can typically be installed using pip:
pip install numpy matplotlib-
Clone this repository or download the 'pathfinding-algo-simulation.py' script.
-
Navigate to the directory containing the script in your terminal.
-
Execute the script using Python:
python pathfinding-algo-simulation.py
This will open a window displaying the maze and a set of radio buttons to select the algorithm for simulation.
UX Enhancements
- Maze Generation
- Allow generating new random mazes.
- Allow a user to define their own mazes (maybe by clicking or loading from a simple text format).
- Speed Control
- Add a slider or input to control the animation speed ('interval' in 'FuncAnimation').
- Reset Button Add a dedicated "Reset Algorithm" button that clears the current algorithm's state (visited, frontier, path) and restarts it without needing to re-select it from the radio buttons. This would be more intuitive than the current implicit reset.
- Execution Allow a user to step through the algorithm one step at a time.