This project generates a random maze and finds the shortest path from a start to an end point using Dijkstra's algorithm. The entire process is visualized in real-time using Pygame.
- Random Maze Generation: Creates a perfect maze using a randomized depth-first search (recursive backtracker) algorithm.
- Graph Conversion: The generated maze is converted into a graph data structure (adjacency list), where each cell is a node and open passages are edges.
- Dijkstra's and A Algorithms*: Implements both Dijkstra's and A* algorithms to find the shortest path between any two cells in the maze. You can toggle between them using the 'T' key.
- Pygame Visualization: Provides a rich graphical interface to view the maze and the pathfinding process.
- Real-time Animation:
- The maze walls are drawn.
- The start (green) and end (red) cells are highlighted.
- The exploration process of Dijkstra's algorithm is animated in light blue.
- The final shortest path is highlighted in yellow.
-
Clone the repository:
git clone https://github.com/06navdeep06/maze-using-Dijkstra-s-Algorithm.git cd maze-using-Dijkstra-s-Algorithm
-
Install dependencies: The only dependency is Pygame. You can install it using pip:
pip install pygame
-
Run the script:
python maze.py
A Pygame window will open, displaying the maze and the animated pathfinding process.
This project was created by Navdeep.