This project is a Maze Solver application built with React. It uses the Breadth-First Search (BFS) algorithm to find the shortest path from the start point to the end point in a maze.
- Generate a random maze
- Load a predefined demo maze
- Visualize the BFS algorithm solving the maze
- Interactively modify the maze by clicking on cells
- Reset the maze to its initial state
The Maze component is the main component that renders the maze grid and controls the maze-solving process. It includes buttons to start the BFS algorithm, reset the maze, load a demo maze, and generate a random maze.
The mazeService module provides functions to generate a random maze, reset the maze, and perform the BFS algorithm to find the shortest path.
- Clone the repository.
- Install the dependencies using
npm install. - Start the development server using
npm start. - Open the application in your browser.
An example of a predefined demo maze:
[
["S", 0, 1, 1, 1, 0, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 0, 1, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 1, 0, 0, 0, 1],
[1, 1, 1, 1, 0, 1, 0, 1, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 1, 1, 1, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 0],
[0, 1, 1, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 1, 1, 1, 0, 1, 0, 0, "E"]
]
Srepresents the start point.Erepresents the end point.0represents a path.1represents a wall.
