This project generates random mazes and solves them using Dijkstra's algorithm to find the shortest path. It features an interactive interface allowing both auto-solve and manual navigation of the maze.
- Random Maze Generation: Generates a random maze using a backtracking algorithm.
- Maze Solver: Solves the maze using Dijkstra's algorithm.
- Interactive Navigation: Allows the user to manually navigate the maze using WASD keys.
- Auto-Solve Option: Option to automatically solve the maze, with the solution path being visually displayed.
- Adjustable Maze Size: The size of the maze can be modified dynamically using an input box.
- Elapsed Time Display: Displays the elapsed time for the auto-solve feature.
- The maze is generated using a backtracking algorithm.
- Starting from the top-left corner, it recursively explores neighboring cells, carving paths (-1) and marking walls (-2).
- The algorithm backtracks when no unvisited neighbors remain, ensuring a perfect maze with one solution.
- Dijkstra's algorithm is used to find the shortest path from the start to the end.
- It explores neighboring cells, updating the shortest path cost, and reconstructs the solution path once the end is reached.
- The path is then marked on the maze (2).
- During the maze generation, the walls (-2) are drawn as black squares, while the open paths (-1) are displayed as white squares.
- The start point is typically highlighted as a red square (1).
- The path solution is displayed as purple squares (2) during the auto-solve process.
Generate Maze: Click the "Generate Maze" button to create a new random maze. Manual Solve: Use the WASD keys to navigate through the maze. Avoid walls (black cells). **Auto Solve: **Click the "Auto-Solve" button to solve the maze automatically using Dijkstra's algorithm. Adjust Maze Size: Click on the Maze Size button , then enter a new maze size in the input box (default: 50x50) and press Enter to update the maze and move the cursor out of the Maze Size box and click it.
- Download and install Processing [use Python Mode]
- Clone this repository or download the ZIP file:
git clone https://github.com/kmusadiqpasha/maze-generator-and-solver
- Open the .pde files for each simulation in Processing.
- Run the sketches and watch the maze come to life!
- This project is licensed under the MIT License - see the LICENSE file for details.