A React-based game where two AI mice compete to reach cheese using different pathfinding algorithms and sabotage tactics.
- 10x10 Maze Board: Fixed-size grid with border walls.
- Guaranteed Paths: Randomly generated mazes always ensure both mice can reach the cheese.
- Multiple Pathfinding Algorithms: A* Search, Breadth-First Search, Depth-First Search, and Bidirectional Search.
- Strategic Sabotage (3 tokens each): AI evaluates removing one wall and placing it elsewhere to help itself and hinder the opponent.
- Real-time Visualization: Step-by-step exploration highlights for each algorithm (visited, exploring, and thinking cells).
- Interactive Controls: Auto Play, single-step, reset, and "New Maze" generation.
- Path Overlay Toggle: Show/hide each mouse's current planned path.
- Speed Control: Adjustable turn interval with visual feedback.
- Game Log & AI Reasoning: Side panels show decisions, exploration steps, and game events.
- Install dependencies:
npm install- Start the development server:
npm start- Open http://localhost:3000 to view it in the browser.
- Select Algorithms for Red and Blue from the dropdowns.
- Generate a New Maze with "New Maze" (paths guaranteed).
- Start with "Auto Play" or use Step for manual turns.
- Toggle Path Overlay to see each mouse's current planned route.
- Win Condition: First mouse to reach the cheese wins.
- Movement: Up to 2 cells per turn along the chosen algorithm's path.
- Sabotage: Consumes 1 token. Removes one wall and places it in another empty cell (mice/cheese cells are excluded). The AI evaluates options and will only sabotage if it yields higher strategic value than moving.
- Forced Movement: If a mouse did not move on its previous turn, it is forced to move on its next turn.
- Turn Order: Red starts; turns alternate. Auto-play advances turns at the selected speed.
- React 18
- Tailwind CSS for styling
- Lucide React for icons
- Real-time pathfinding visualization with algorithm-specific highlighting, including bidirectional forward/backward coloring
- Maze size is fixed at 10x10.
- Both mice use the same emoji (rings/colors differentiate positions).
- Speed slider maps to turn interval; labeling may feel inverted depending on expectation.
├── public/
│ └── index.html
├── src/
│ ├── algorithms/ # Pathfinding algorithms (BFS, A*, DFS, Bidirectional)
│ │ ├── bfs.js
│ │ ├── astar.js
│ │ ├── dfs.js
│ │ ├── bidirectional.js
│ │ └── index.js
│ ├── components/ # React UI components
│ │ ├── MazeGrid/
│ │ ├── Controls/
│ │ ├── SidePanel/ # AI calc, stats, game log
│ │ ├── AlgorithmSelectors/
│ │ ├── WinnerOverlay/
│ │ ├── FullscreenView/
│ │ ├── SpeedControl/
│ │ ├── ErrorBoundary/
│ │ └── Tokens/
│ ├── core/ # Pure game logic (no React)
│ │ ├── constants.js
│ │ ├── engine.js
│ │ ├── ai.js
│ │ └── maze.js
│ ├── hooks/ # Custom React hooks
│ │ ├── useVisualization.js
│ │ ├── useAutoplay.js
│ │ └── useGameState.js
│ ├── __tests__/ # Test files
│ │ ├── algorithms/
│ │ ├── components/
│ │ └── core/
│ ├── App.js
│ └── MouseMaze.jsx # Main orchestrator component
├── package.json
└── README.md
Run the test suite:
npm testTest Coverage:
- ✅ 133 tests passing
- ✅ Algorithm correctness (BFS, A*, DFS, Bidirectional)
- ✅ Core game engine logic
- ✅ Maze generation and validation
- ✅ UI component behavior (Controls, SpeedControl, AlgorithmSelectors, FullscreenView)
- Modular Design: Separated concerns with pure functions for game logic, isolated algorithms, and reusable React components
- Test-Driven: Comprehensive test coverage ensures algorithm correctness and game logic reliability
- Performance: Optimized pathfinding with visualization that doesn't block the UI
- Maintainable: Clear separation between game state, UI, and algorithms makes the codebase easy to extend