Each car is controlled by a vector of accelerations (DNA). The goal is to go as far as possible on the track.
✨The obstacles can be moved with the mouse.
Navigation
1. The DNA of Cars
Each car has a vector of accelerations:
- It’s a list of small vectors applied at every time step.
- This determines its trajectory.
DNA schema:
Car DNA = [ (→), (↗), (↑), (↗), (→), (↓), ... ]
2. Life Cycle of a Generation
The genetic algorithm follows this cycle:
- Initialization: create a population of cars with random DNA.
- Simulation: each car follows its DNA until it dies or reaches the finish line.
- Evaluation: compute its fitness (distance traveled, bonus if reached).
- Selection: keep the best individuals (elitism).
- Crossover: mix DNA from two parents.
- Mutation: randomly change some genes.
- New generation: repeat the process.
3. Fitness and Evolution
- Fitness = distance reached (plus a bonus if the finish line is crossed).
- Cars that die too early get a penalty.
- Over generations, the population learns to avoid obstacles better.
Generation 1 : random cars (all die quickly) Generation 5 : some pass the first obstacle Generation 15: a few get near the finish Generation 50+: most can finish successfully