Skip to content

🧬 Self-Parking Car Evolution

project
765

Training the car to do self-parking using a genetic algorithm

  • Genetic
  • Algorithms
  • Three.js
  • Cannon.js
  • TypeScript

About

Self-Parking Car Evolution teaches cars to park themselves using a genetic algorithm. The whole evolution runs in your browser: you watch each generation try to park in a 3D simulation and can tune the training as it goes.

Each car is controlled by simple linear formulas whose coefficients are encoded in a 180-bit genome. The cars that get closest to the parking spot are more likely to be selected as parents, and crossover and mutation produce the next generation. The first generations drive around at random, and by roughly the 40th generation the cars start heading for the parking spot.

The genetic algorithm itself takes less than 500 lines of TypeScript. The rest is the React app, a Three.js 3D world and Cannon.js physics.

Achievements

4