Byproduct
Evolves tiny robot brains in simulation, then flashes them to a rover
The problem
Teaching a small robot to roam a room without hitting things usually means hand-writing control rules or training a large model that will never fit on a cheap microcontroller.
I wanted a controller small enough to run on an ESP32, learned rather than hand-coded, and honest about what the real car can sense, so that what works in simulation still works on the floor.
What I built
- Every brain is the same tiny recurrent network: about 30 to 40 weights, a few hundred bytes. No gradients and no training data; brains that find food reproduce and brains that don't die out.
- The engine is fully deterministic. Seeded random numbers mean the same run replays frame for frame on any machine, which makes tuning and comparisons trustworthy.
- Learning happens through a curriculum. A population is promoted from easy worlds to harder ones, gaining new inputs and outputs without losing what it already learned.
- A trainer turns a plain-English goal into milestones, builds the arena for each one, and checks that the brains only train on senses the real hardware actually has.
- The winning brain is exported as generated firmware with the same math as the simulation, plus test runs and a pre-flight check before it is flashed to the car.
What it does
- Live canvas of the population: agents (triangles), food (orange) and walls, with the current course and its pass rule written underneath.
- Type a goal into the trainer chat and it sets a mission plan, picks what the brains can sense, and starts training.
- Milestone progress, population, alignment and best-generation charts update while training runs.
- Snapshots are saved at every milestone and can be reloaded or used as the source for an export.
- Export panel picks a brain and a hardware target and builds firmware for the rover.
Built with JavaScript (no dependencies), HTML canvas, Node.js, ESP32 firmware (C++), Local LLM, 2026.