Turbo Rally: AI Academy

Forty cars, each driven by its own tiny neural network, learn to race through traffic by evolution. Nobody tells them how to drive: after every round the fastest drivers become parents of the next generation, and every round is on a brand-new track, so they cannot just memorise the road.

GEN1
ALIVE40
TIME0.0
BUMPS0
RED CAR0KM/H

the learner you're following the nearest other learners ahead (see-through: learners can't hit each other) traffic to get past

How it works

The driver. Each car is steered by a neural network with 11 inputs, 10 hidden neurons and 2 outputs. It sees where it is across the road, how fast it is going, how sharply the road bends 4, 12, 24, 40 and 64 segments ahead, whether a hill is coming, and the traffic: how close the nearest car ahead is, which side of it that car is on, and whether a car is right in its path. Its outputs are steering (left, straight, right) and pedals (accelerate, coast, brake). Those 142 numbers, the network's weights, are all a driver is.

The race. Every generation gets a brand-new random track (by default in a random style: forest, desert, night, fog, snow or mountains) with 36 slower cars that drift across the road. All forty learners race it at once for 40 seconds, with exactly the physics of the real game; they pass through each other, but not through traffic. The score is the distance covered, which is the same as the average speed, minus a small penalty per collision.

Evolution. When the race ends, the four best drivers go into the next generation unchanged and two brand-new random drivers join to keep variety. The other 34 are children of good parents: each takes weights from two of them, mixed at random, and a few weights get small random changes (mutations). If no better driver appears for a while, the mutations get bigger.

Keeping it honest. A simple hand-written rule, "flat out, steer back to the middle", races every generation on the same track and traffic (the dashed line in the chart). Without traffic that rule is already the fastest possible driver on these tracks, so beating it means the network has learned something the rule cannot do: getting past traffic. The champion is chosen on test tracks the population never races on, so it has to drive well on roads it has never seen. "Watch champion" runs it on the real stage of the scenery on screen, with traffic, and compares its time with the simple rule's.

What to expect. In our tests, champions typically beat the simple rule on unseen test tracks within 20 to 40 generations (around 215 km/h against 180), and finish almost every real stage faster than it. With their traffic sensors switched off, the same drivers crash into traffic and lose most of that advantage, so they really are using what they see. Even good drivers bump into a car about once per race: with 36 cars drifting across the road, a hand-written driver that can see every car's position and where it is about to drift does no better. Now and then a champion still fails on a stage it was not trained on.

Watching. The red car is the one the camera follows. "Best" (the default) rides with last generation's winner. "Pack" rides in the middle of the field, where you see more of the population, including the new random drivers and mutated children, who crash a lot.