This is a Python program that implements a maze solver using depth-first search (DFS) and breadth-first search (BFS). The solver reads a maze from a text file and finds a path from the start ('A') to the goal ('B').
- Interactive Maze Builder (
create.py) - Supports DFS (stack-based) and BFS (queue-based) search strategies
- Real-time visualization of explored and solution paths
- Difficulty rating based on nodes explored
- Text-based and graphical interface options
- Python 3.x
pygamelibrary
Install pygame if you haven't:
pip install pygameCreate a maze by runnig create.py :
- Click to place/remove walls.
- Press
Sthen click to place start. - Press
Gthen click to place goal. - Press
Enterto save the maze.
OR
Create a text file (e.g., maze1.txt) with:
Arepresenting the starting position.Brepresenting the goal.#representing walls.- Spaces (
) representing open paths.
To solve the maze place your file in gui.py for GUI based representation.
Edit the last line of gui.py to switch algorithms:
visualize("maze.txt", use_bfs=True) # True for BFS, False for DFSOR
Execute the script to solve the maze:
python solve.pymaze-solver/
│── solver.py # Maze solver implementation
│── create.py # Create you own maze
│── gui.py # GUI based representation
│── solve.py # Script to test the maze solver
│── maze1.txt # Sample maze file