Micromouse real-time algorithm simulator
After earning runner-up at the 2011 IEEE Micromouse contest, I built a real-time web simulator to keep improving the floodfill algorithm without the edit-flash-run cycle. It ran the same C++ logic natively on a PC and streamed each step live to the browser.
Story
After placing at the 2011 IEEE Micromouse contest with Double Decker, I wanted to keep developing the algorithm without the slow embedded iteration loop. Every change meant editing C++, recompiling, flashing the AVR, and running the physical robot. The simulator cut all of that out.
The browser interface let me draw or load mazes at 6x6, 8x8, or the full 16x16 competition size and watch the algorithm explore step by step. The key insight was running the exact same C++ algorithm natively on the PC rather than inside any emulator. That gave me full IDE support: breakpoints, variable watches, and instant recompiles. No more stopping a live robot run or parsing serial logs to understand what was happening inside 2 KB of memory.
Getting live state into the browser was the engineering challenge. WebSockets did not exist in 2011. I solved it by repurposing the Flash XML Socket bridge I had originally written for Pechali.com's real-time chat, adapting it as a localhost TCP relay between the running C++ process and the browser.
The result was night-and-day. A single recompile and refresh showed the new path on screen. No batteries, no motors, no wear on hardware. The faster the feedback loop, the better the final algorithm.
Do not follow what you have no knowledge of. Surely the hearing, sight, and heart will all be questioned.
Impacts
- Reduced algorithm iteration from a multi-step flash-and-run cycle to a single recompile and browser refresh
- Enabled full IDE debugging, breakpoints, variable watches, and instant recompiles, on the exact C++ code that ran on the AVR
Challenges & Solutions
Challenges
- Streaming live algorithm state to the browser in 2011, before WebSockets existed
- Simulating AVR behavior accurately enough that algorithm fixes would transfer directly to hardware
- Keeping the browser rendering responsive during real-time step-through of a full 16x16 maze
Solutions
- Repurposed the Flash XML Socket bridge originally built for Pechali.com's live chat as a localhost TCP relay between the native C++ process and the browser
- Ported the floodfill algorithm exactly to desktop C++ and ran it natively on the PC, guaranteeing behavioral parity with the robot without emulating the MCU
- Designed a compact binary protocol that transmitted only the changed state per step, keeping socket payloads small and the display fluid
