Menu

1 / 11

Self-driving cars that learn by deep Q-learning, with drift and reverse, in pure KingCobra

DEV Community: machinelearning·Divyanshu Sinha·12 days ago
#DsoFiGA6
Long article (1806 words) — no AI summary yet.
Reading 0:00
15s threshold

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 , 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

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.

The result

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…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.