Self-driving cars that learn by deep Q-learning, with drift and reverse, in pure KingCobra A developer built a self-driving-car simulator in which every car on the road is driven by a single shared Double DQN network, written entirely in the developer's own KingCobra language using only its standard library. The cars use a dynamic bicycle tyre model with a friction circle, enabling understeer, handbrake drift and reverse, and the shared network completed 100% of laps on three unseen tracks at about 14 m/s with no wrecks after roughly 1.7 minutes of training on one CPU core for a network of about 21,000 parameters. I built a self-driving-car simulator where every car on the road is driven by the same neural network , trained with Double DQN. The cars have a proper dynamic tyre model, so they can understeer, drift with a handbrake and drive in reverse . Everything is written in KingCobra https://github.com/DivyanshuSinha136/KingCobra , my programming language, using only its standard library std.nn , std.http , std.json and std.system . There is no Python and there are no external dependencies. Repo: https://github.com/DivyanshuSinha136/KingCobra-Self-Driving-Car-DQN https://github.com/DivyanshuSinha136/KingCobra-Self-Driving-Car-DQN The dashboard, captured from the real app: the AI and four NPC cars on a track the network never saw, all driven by one network. | Laps | 100 % completed on 3 tracks the network never saw, at about 14 m/s, with no wrecks | | Training | 1.7 minutes on one CPU core, for a network of about 21,000 parameters | | Agent | one shared Double DQN, 3-step returns, Huber loss, gradient clipping, soft target updates, 12 actions steering × pedal | | Physics | dynamic bicycle model, tyre friction circle, handbrake drift, reverse gear, soft walls, car-to-car collisions | | Reproducible | one seed controls everything, and two runs with the same seed give bit-identical models | 47 seconds recorded from the real dashboard: AI traffic on an unseen track, the chase camera, the drifter model, a human adding a handbrake drift and reversing, then the AI taking back over. You need KingCobra 1.0 kingcobra on your PATH , and node only for the front-end tests. git clone https://github.com/DivyanshuSinha136/KingCobra-Self-Driving-Car-DQN cd KingCobra-Self-Driving-Car-DQN make serve open http://127.0.0.1:8766, two pre-trained models are included make eval laps on seen and unseen tracks, with traffic make train retrain from scratch about 2 minutes on one CPU core make test 67 KingCobra tests plus front-end tests No make ? Every target is one command: kingcobra run src/main.kc