An interactive pathfinding visualizer built using Python and Pygame. This project demonstrates how popular graph traversal and shortest-path algorithms work by animating their execution on a grid.
Users can create walls, weighted nodes, generate random mazes, and compare the behavior of different algorithms in real time.
- Interactive grid-based interface
- Visualize multiple pathfinding algorithms
- Add and remove walls
- Create weighted nodes
- Generate random mazes
- Real-time animation
- Adjustable visualization speed
- Live statistics panel
- Guarantees shortest path in an unweighted graph.
- Uses a queue.
- Explores one branch completely before backtracking.
- Uses a stack.
- Does not guarantee shortest path.
- Finds the shortest path with weighted nodes.
- Uses a priority queue.
- Optimized shortest-path algorithm.
- Uses Manhattan distance heuristic.
- Python 3
- Pygame
- Heap Queue
- Collections (Deque)
- VS Code
| Key | Action |
|---|---|
| 1 | Wall Mode |
| 2 | Start Node |
| 3 | End Node |
| 4 | Weight Mode |
| V | Start Visualization |
| TAB | Change Algorithm |
| C | Clear Grid |
| R | Generate Random Maze |
| + | Increase Speed |
| - | Decrease Speed |
- Left Click → Draw
- Right Click → Erase
Clone the repository:
git clone https://github.com/your-username/Pathfinding-Visualizer.gitMove into the project directory:
cd Pathfinding-VisualizerInstall dependencies:
pip install pygameRun the project:
python main.py
Pathfinding-Visualizer/
│
├── main.py
├── README.md
├── requirements.txt
└── screenshots/
| Algorithm | Shortest Path | Weighted Graph |
|---|---|---|
| BFS | Yes | No |
| DFS | No | No |
| Dijkstra | Yes | Yes |
| A* | Yes | Yes |
- Diagonal movement
- Additional algorithms
- Custom maze generators
- Dark/light themes
- Save and load maps
This project is open-source and available under the MIT License.
Anendra Narayan Dixit