A random maze generator with a built-in solver.
Check out the live demo here.
- Generate Maze: Click the "Generate Maze" button to create a new random maze.
- Solve Maze: Click the "Solve Maze" button to see the maze being solved automatically.
- Maze Size: Use the slider to adjust the size of the maze.
- Maze Simplicity: Use the slider to adjust the simplicity of the maze.
- Player Movement: Use the arrow keys or WASD keys to move the player through the maze.
The maze is generated using a recursive backtracking algorithm. Here's a brief overview of the process:
- Initialization: The maze is initialized with all walls intact.
- Starting Point: The algorithm starts at a random cell and marks it as visited.
- Recursive Backtracking: The algorithm randomly selects an unvisited neighboring cell, removes the wall between the current cell and the selected cell, and moves to the selected cell. This process is repeated until all cells have been visited.
- Extra Paths: Additional paths are added to increase the simplicity of the maze based on the selected simplicity level.
The maze is solved using a depth-first search (DFS) algorithm. Here's a brief overview of the process:
- Initialization: The algorithm starts at the beginning of the maze.
- Depth-First Search: The algorithm explores each path recursively until it reaches the end of the maze.
- Path Animation: The path taken by the algorithm is animated on the canvas.
The player can navigate through the maze using the arrow keys or WASD keys. The player's movement is restricted by the walls of the maze.
This project is licensed under the MIT License - see the LICENSE file for details.
