A lightweight, high-performance web-based simulator for Micromouse maze design and algorithm testing. Built with modular Vanilla JavaScript, HTML, and CSS.
Click here to try the Simulator
- 📱 Mobile-First Design:
- Responsive Sidebar: Slide-out drawer on mobile with backdrop dimming and "click-to-close" logic.
- Global Toggle: Decoupled sidebar toggle button located in the global header.
- 👆 Advanced Gestures:
- Pinch-to-Zoom: Native-like pinch zooming on touch devices.
- Pan & Drag: Move the maze view freely using touch (mobile) or mouse drag (desktop).
- 🌗 Smart Theme Toggle: Animated Sun/Moon switch for Dark/Light mode.
- ✨ Adaptive Overlay: Status info box automatically fades to transparent when overlapping with the maze grid.
- 🎞️ Enhanced Visualization: New backtracking animation (shrinking nodes) for clearer DFS execution.
- 📸 Image Import: Includes a Python Companion Tool to convert real-world maze photos into compatible
.jsonmaps with an interactive GUI editor.
- Web Worker Support: Heavy algorithm calculations run in a background thread, ensuring the UI never freezes, even on large maps.
- Modular Design: Codebase split into logical modules (Renderer, Interactions, Animator) for easy maintenance.
Includes standard algorithms with Visual Animations:
-
🎬 Dual Animation Modes:
-
Map Calculation: Visualizes the "search wave" propagation (Flood Fill, BFS, Dijkstra).
-
Physical Simulation: Simulates a single mouse agent moving and backtracking (DFS, Wall Follower).
-
🚀 Speed Control: Adjust animation speed in real-time with a slider.
-
Supported Algorithms:
-
🌊 Flood Fill: The classic Micromouse algorithm (guaranteed shortest path).
-
⭐ A Search:* Heuristic-based search (Manhattan distance).
-
🔍 Dijkstra: Uniform cost search.
-
🌀 DFS: Depth-First Search with backtracking visualization.
-
⬅️ / ➡️ Wall Follower: Left/Right-Hand rules simulation.
This project includes a powerful offline Python tool located in the tools/ directory. It allows you to convert photos of physical mazes (Classic 16x16 or Half-size 32x32) into JSON format for the simulator.
Features:
- 🖼️ Auto-Detection: Automatically detects maze size from filenames.
- ✨ Interactive GUI: Verify walls and set start/goal positions visually.
- 📐 Auto-Correction: Aligns grids and fixes perspective issues.
👉 Check out the Tool Documentation here (For Traditional Chinese instructions, see 中文說明)
- Dark/Light Theme: Auto-detects system preference.
- 🖱️ Mouse Wheel Zoom: Smooth zooming logic centered on the maze.
- 🌍 Multi-Language: English, Traditional Chinese (繁體中文), and Japanese (日本語).
- 📊 Path Analysis: Real-time stats for Steps, Turns, and Straightaways.
The project follows a modular architecture:
micromouse-sim/
├── index.html # Main entry point
├── style.css # Styling and CSS variables
├── maps/ # Pre-loaded map files (.json)
├── tools/ # 🐍 Python Utility Tools
│ ├── maze_converter.py # Image to JSON converter & editor
│ ├── requirements.txt # Python dependencies
│ ├── README.md # Tool documentation (English)
│ └── Readme_zh.md # Tool documentation (Chinese)
│
├── js/
│ ├── setup.js # Global variables & DOM initialization
│ ├── ui_control.js # Main controller & Worker communication
│ ├── maze_core.js # Data model & Hex compression logic
│ ├── maze_worker.js # Background thread for heavy algorithms
│ ├── i18n.js # Internationalization
│ ├── maps_index.js # Map file registry
│ │
│ ├── ui/ # UI Modules
│ │ ├── animator.js # Animation logic (Step/Time-based)
│ │ ├── interactions.js # Mouse/Touch events (Drag-to-draw)
│ │ └── renderer.js # SVG & Grid rendering
│ │
│ ├── utils/ # Utility functions
│ │ └── path_analyzer.js # Path statistics calculation
│ │
│ └── algos/ # Algorithm implementations
│ ├── astar.js
│ ├── bfs.js
│ ├── dfs.js
│ ├── dijkstra.js
│ ├── flood_fill.js
│ ├── manhattan.js
│ └── wall_follower.js
Want to learn more about real-world Micromouse competitions? Check out our curated list of events and resources:
You only need a modern web browser (Chrome, Firefox, Edge, Safari). No npm or backend required.
Note: Due to browser security policies (CORS) regarding Web Workers, this project cannot be run directly by opening the
index.htmlfile path (file://) in some browsers.
- Clone the repository:
git clone https://github.com/yingchaotw/micromouse-sim.git
- Run a local server (Recommended):
- VS Code: Install "Live Server" extension and click "Go Live".
- Python:
python -m http.server - Node:
npx serve
- Open
http://localhost:5500(or your port) in the browser.
-
Setup: Select a size preset (16x16 / 32x32) or enter custom dimensions.
-
Draw Walls:
- Select "Edit Wall" mode.
- Draw: Click and drag across grid lines.
- Move/Pan: Click and drag on empty space (Desktop) or use one finger (Mobile) to pan the view.
- Zoom: Use Mouse Wheel (Desktop) or Pinch gesture (Mobile).
-
Configure: Set Start (S) and Goal (G) points.
-
Simulate:
- Choose an algorithm.
- Check "🎬 Animate" for visualization.
- Adjust the Speed Slider to control playback.
- Click Run.
Contributions are welcome!
- Fork the project.
- Create your feature branch (
git checkout -b feature/NewFeature). - Commit your changes.
- Push to the branch.
- Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
- Inspired by standard Micromouse competition rules.
- Algorithms based on Graph Theory and Maze Solving techniques.