How the AI in Neuro Racer learns to drive
Guide · Updated 22 October 2026
In Neuro Racer, cars learn to drive a track you drew yourself – without anyone explaining what a corner is. The method behind it is called neuroevolution. In this article we explain step by step what happens, and why Neuro Racer makes it so easy to watch.
The brain: a tiny neural network
Every car has a small neural network. That sounds like high tech, but at its core it is a calculation rule: a few numbers go in, get multiplied by weights and added up, and a few numbers come out. Whatever the network “can do” lives entirely in those weights.
Eight values go in. Seven of them come from distance sensors fanned out to the front: straight ahead, slightly angled, more angled and almost to the side, each on the left and right. Each one measures how far it is to the edge of the track. The eighth value is the car's own speed. Two values come out: how hard to steer, and whether to accelerate or brake.
In between sits a so-called hidden layer of 4 to 16 neurons – in Neuro Racer you set the number yourself. Each neuron computes an intermediate value from all eight inputs, and the two outputs come from those intermediate values. With eight neurons a network has just under a hundred weights. That is all it takes to drive a track.
At the start: pure chance
At the beginning, every car gets random weights. Some networks just always steer left, some never accelerate, some drive straight into the wall. That's intentional: among hundreds of random networks there are always a few that happen to do something useful – like steering slightly away when the wall on the right gets closer.
Selection: whoever gets furthest
A generation drives until every car has crashed or finished, or time runs out. A car is out if it touches the wall, makes no progress for three seconds or drives clearly backwards. Then every car gets a score, called “fitness” in technical terms: how much of the track it covered. Cars that reach the finish get a bonus that is bigger the faster they were.
Now comes the crucial step. The best two percent are carried over to the next generation unchanged – so the best so far is never lost. All other slots are filled with offspring of the top 15 percent. The better a car did, the more often it is chosen as a parent.
Crossover and mutation
An offspring usually comes from two parents: for each weight, chance decides whether it comes from one parent or the other. Sometimes only one parent is copied. Then comes mutation: some of the weights are nudged by a small random amount. How many is set by the mutation rate, which you can adjust between 1 and 40 percent.
Crossover combines what already works. Mutation tries something new. Together they make sure each generation can drive a little better than the last – not because anyone improves the networks, but because whatever happens to work better wins out.
Why this works without “learning” in the usual sense
Many AI systems learn with a method called gradient descent: for every decision they are told how wrong it was and adjust their weights in a targeted way. Neuro Racer doesn't do that. No car ever finds out why it hit the wall. Only the result at the end counts. That is slower and less precise, but easy to understand – and you can watch every generation as it happens.
What you can watch in Neuro Racer
- The first generations: chaos. Almost every car is out within seconds.
- The first breakthrough: suddenly one car makes the first corner. One generation later, many do.
- Learning to brake: because the cars have limited grip, fast cars slide out of tight corners. Eventually networks that lift off before corners take over.
- Fine-tuning: once many cars finish, time decides. Now the line gets refined, and lap times keep slowly dropping.
The “Sensors” button shows the rays a car uses to “see” the track. The stats show how progress develops over the generations, along with the network of the best car.
Experiments to try
- Mutation rate: train the same track once at 2 and once at 30 percent. With a very high rate, learned behaviour often gets lost faster than new behaviour appears.
- Network size: four neurons are enough for an oval. For a tight serpentine, more help.
- Generalisation: train on one track and then rebuild it. The cars keep their networks. Can they drive the new track too? Then they really learned to drive rather than memorising one track.
- Population size: with 50 cars it often takes a long time for one to have the right idea. With 1000 it goes faster, but needs more computing power.
Where else neuroevolution is used
The same principle – generate random variants, keep the best, repeat – is used in research to develop controllers for robots, train game characters or optimise shapes. Large language models and image recognition usually rely on other methods. But for small control tasks like in Neuro Racer, neuroevolution is a vivid and surprisingly effective approach.