Rookie is a page where you draw any race track with your finger, and fifty AI cars learn to drive it in front of you, from nothing, in under a minute. Then you race the one you trained.
No training data. No dataset. No backprop. No ML library. Everything is written from scratch and runs on your own device.
What is under the hood
- Each car sees the world through 7 distance sensors fanned out from 75° left to 75° right, plus its own speed. Eight numbers between 0 and 1, sixty times a second. It never knows where it is on the track or which way round it goes.
- Its brain is a feed-forward neural network: 8 inputs, 6 hidden neurons, 2 outputs (steering and pedal), tanh on every neuron. 68 weights in total. Those 68 numbers are the entire driver.
- It learns by neuroevolution, a genetic algorithm over the network's weights. Rank all fifty by how far they got. The best four go through untouched, so the best can never get worse. Every other car is bred: parents picked as the best of three from the better half, weights crossed over from one parent or the other, then about one in five nudged at random. If progress stalls, the mutations grow 30% per generation and six complete newcomers join.
- Generation 1 is a pile-up. In the run in this film, the first clean lap came in generation 5. Nobody drew the racing line you see wearing into the road. It is simply where the survivors kept driving.
The numbers
- 200 random tracks nobody had seen: all 200 learned to a clean lap. Median generation 6.
- One physics step for all fifty cars takes about 0.03 ms on a laptop, around 600× faster than real time.
- Deterministic: same seed, same evolution, weight for weight.
- The track and the trained driver fit after the # of a link, so you can send someone your rookie to race.
- The whole page is about 58 kB. No account, no server, no tracking.
Everything in the film is real footage from the page or drawn from the real numbers in the code.
Try it: pratyushshivam.github.io/rookie/
Source: github.com/pratyushshivam/rookie