Every agent's "chromosome" is a sequence of steering genes — one turn value per leg of the crossing. Each generation, every agent drives from the start line toward the goal using its own chromosome to decide how hard to turn at each moment, weaving around the obstacle field (or not). When the timer for the generation runs out, each agent is scored by how close it got to the goal — reaching it outright earns a large bonus, and colliding with an obstacle costs a penalty.
fitness = 1 / (1 + closestDistanceToGoal)
+ 1.5 · [reachedGoal] − 0.25 · [collided]
child.gene[i] = coinFlip() ? parentA.gene[i] : parentB.gene[i] (crossover)
child.gene[i] += mutationRate ? random(-0.6, 0.6) : 0 (mutation)
- Population size — how many agents attempt the crossing each generation; a larger population explores more chromosome combinations per generation but costs more to render.
- Mutation probability — the chance any single steering gene gets randomly perturbed when a child is created; too low and the population stalls on a mediocre path, too high and it never converges.
- Generation speed — how fast simulated time runs per generation; higher settings let you watch dozens of generations evolve in seconds.
- The top ~12% of each generation (the elite) survive unchanged into the next one — this elitism guarantees the best fitness ever found never gets lost to an unlucky mutation.
Real-world relevance: this select → crossover → mutate loop is the same one used by genetic algorithms tackling scheduling, circuit layout, robot gait design and neural-network weight search — anywhere the fitness landscape is too rough or discontinuous for gradient-based optimizers to climb reliably.