A web-based interactive maze solver that allows you to create custom mazes and find the shortest path using the Breadth-First Search (BFS) algorithm.
This maze solver uses Breadth-First Search (BFS), a graph traversal algorithm that explores nodes level by level:
- Initialization: Start from the starting point and mark it as visited
- Queue-based traversal: Use a queue to explore cells in order
- Exploration: For each cell, check all four adjacent neighbors (up, down, left, right)
- Path tracking: Keep track of each cell's predecessor to reconstruct the path
- Termination: Stop when the end point is reached or all reachable cells are explored
- Path reconstruction: Backtrack from the end to the start using the predecessor chain
BFS guarantees finding the shortest path in an unweighted grid, making it ideal for maze solving.
- Customizable Grid Size: Generate mazes from 5x5 up to 50x50
- Adjustable Cell Size: Change cell dimensions from 5px to 30px for better visibility
- Drawing Modes:
- Wall (obstacles)
- Path (walkable cells)
- Start point (green)
- End point (red)
- Click & Drag: Draw continuously by holding the mouse button
- Undo/Redo:
- Undo button or
Ctrl+Zto revert changes - Redo button or
Ctrl+Yto restore undone changes - Tracks up to 1000 edits
- Undo button or
- Clear Maze: Reset the entire maze while keeping the border walls
- BFS Algorithm: Finds the shortest path from start to end
- Visualization Speed: Choose between Fast, Normal, or Slow animation speeds
- Visual Solution: Highlights the solution path with animated progression
- Step Counter: Displays the number of steps in the shortest path
- No Path Detection: Alerts when the maze is unsolvable
- Auto-Reset: Solution clears when editing the maze after solving
A custom maze ready to be solved with start (green) and end (red) points marked
The shortest path highlighted after running the BFS algorithm
- Set Maze Size: Enter a number between 5-50 and click "Generate Maze" (or press Enter)
- Adjust Settings (Optional):
- Change cell size (5-30px) for better visibility
- Set visualization speed (Fast/Normal/Slow)
- Design Your Maze:
- Select a drawing mode (Wall, Path, Start, or End)
- Click or drag on cells to draw
- Use
Ctrl+Zto undo orCtrl+Yto redo
- Place Start & End: Mark exactly one start point and one end point
- Solve: Click "Solve Maze" to find and animate the shortest path
- View Results: The solution path will be displayed with the total step count
Simply open index.html in a web browser to start using the maze solver!