Darwin's Garage

Twenty-four piles of scrap, no design and no plan. Just selection, crossover, and mutation. Drag the generation slider and watch junk teach itself to climb.

Cutting the first 24 chassis out of scrap…

Evolving…

The floor

Every car in this generation. Tap one to watch its run.

Evolve a car out of scrap, in your browser

Darwin's Garage is a genetic algorithm car evolution simulator. It opens with 24 vehicles built out of random numbers: a polygon chassis of five to eight vertices, wheels bolted to random corners at random radii, each wheel with its own torque. Nobody designed any of them, and most of generation 0 tips over inside a few metres.

Every car then drives the same hill course inside a Matter.js physics simulation, and the distance it covers before it flips, stalls, or runs out of time becomes its fitness. Tournament selection picks the parents, crossover splices two chassis into a child, mutation nudges the wheels, and the next generation rolls out. Forty generations later the best car usually clears the full 720 metres. Nobody drew that shape. Selection found it.

What the three operators do

  • Selection picks parents by running small tournaments, so a mediocre car still gets an occasional shot and the population does not collapse onto one shape by generation 3.
  • Crossover cuts two parent chassis apart and splices the halves, which is where genuinely new silhouettes come from.
  • Mutation jitters wheel radius, wheel position, and torque by small amounts. Set it too high and evolution never settles; too low and it stalls on the first hill.

The fitness curve in the HUD is the honest record. The yellow line is the best car of each generation and the grey line is the population average. Once the two converge, evolution has run out of ideas.

Questions

Is this like BoxCar2D?

Same experiment, and it exists because BoxCar2D was a Flash app and browsers dropped Flash at the end of 2020. Darwin's Garage runs in plain JavaScript, so there is no plugin and nothing to install. What is different here: you can scrub back through every generation, watch any individual car instead of only the leader, and send a car to someone as a link.

What is a genetic algorithm car evolution simulator?

A program that breeds vehicles instead of designing them. You define what good means (here it is distance along a hill), generate random candidates, keep the ones that score well, mix and mutate them, and repeat. Cars make the idea legible, because the fitness function plays out in physics you can watch rather than sitting in a number.

Can I evolve a car on my phone?

Yes. The simulation runs on your device, the layout stacks into one column, and the controls are sized for thumbs. It is 40 generations of real physics, so an older phone takes longer to fill the slider, but it fills.

Is it really evolving, or just picking random winners?

Watch the fitness curve. Generation 0 averages a handful of metres. By generation 20 the best car is usually finishing the course. Random search would give you a flat line with noise on it, not a staircase.

Can I share a car I evolved?

Every car has a share button that writes its genome into the URL. There is no server and no database row; the link itself carries the car. Open it and you get that exact vehicle on that exact track, because the physics is seeded and deterministic.

View the source on GitHub