AI Learns to Drive (Neuroevolution) illustration

AI Learns to Drive (Neuroevolution)

Each car on this track is driven by a tiny neural network — five raycast distance sensors feed a fixed 5→6→2 multilayer perceptron whose outputs are steering and throttle. Nobody programs the driving: a genetic algorithm evolves the weights. Every generation the whole population drives simultaneously, fitness is measured as progress around the track, stalled and crashed cars are eliminated, and the next generation is built from the best drivers by elitism, tournament selection and Gaussian mutation. On default settings the population goes from immediate pile-ups to clean laps within a few dozen generations — follow it on the generation counter, the best-fitness curve and the highlighted leader with its sensor rays drawn. Sliders control population size and mutation strength, a fast-forward box runs many physics steps per frame, and a button generates a fresh random track to test whether the evolved drivers generalise.

Runs 100% in your browser — models are trained and computed locally on your device.

Notes

  • This is neuroevolution, not gradient-based reinforcement learning: no rewards are backpropagated and no value function is learned — selection on total fitness does all the credit assignment.
  • Fitness is the angle travelled around the closed course (continuous checkpoint progress), and cars that stop making progress for a few seconds are killed early — without that stall rule, standing still would be a safe local optimum.
  • Elitism copies the best genomes unchanged into the next generation, guaranteeing the best-fitness curve never moves backwards; mutation σ controls the explore/exploit balance and is the first thing to tune if progress plateaus.
  • The five range sensors make the policy almost track-independent — evolved drivers often transfer to a brand-new track immediately, which you can test with the new-track button.
  • Runs 100% in your browser — models are trained and computed locally on your device.