MazeSolver is a Python-based application that generates and solves mazes using a graphical interface built with the tkinter library. The project demonstrates concepts such as maze generation, pathfinding, and visualization techniques.
- Maze Generation: Randomly generates mazes of varying sizes using a recursive backtracking algorithm.
- Maze Visualization: Displays the maze and its walls using a graphical interface.
- Pathfinding: Solves the maze by finding a path from the start to the end, with a visual representation of the solution.
-
Maze Generation:
- The maze is represented as a grid of cells.
- Walls are created between cells, and a recursive backtracking algorithm is used to "break" walls and create a solvable maze.
-
Maze Solving:
- A depth-first search (DFS) algorithm is used to find a path from the top-left corner to the bottom-right corner of the maze.
- The solution path is visualized in real-time.
- The algorithm marks the path taken and backtracks when it encounters dead ends.
-
Visualization:
- The
tkinterlibrary is used to draw the maze, walls, and solution path on a canvas.
- The
main.py: Contains the core logic for maze generation, solving, and visualization.tests.py: Includes unit tests for validating the functionality of the maze generation and solving algorithms.
- Ensure you have Python 3 installed on your system.
- Clone the repository and navigate to the project directory:
git clone https://github.com/IrishBanga/mazesolver.git cd mazesolver - Run the application:
python main.py
- A window will open displaying the generated maze. Watch as the maze is solved in real-time!
- Python 3.x
tkinter
To run the unit tests, execute the following command:
python tests.py