Self-Driving Car with a Hand-Built DQN

(Personal Project - written entirely in JavaScript)

Reinforcement LearningDQNNeural NetworksJavaScriptBackpropagationLinear Algebra

Overview

With the rise of self-driving cars, I wanted to understand how they make decisions at the algorithmic level. I built a simple driving simulation in JavaScript where a virtual car learns to steer through traffic and avoid crashes. To make it learn, I designed a custom reward algorithm and implemented a Deep Q-Network (DQN) entirely from scratch.

Driving simulator

What I Did

I created every part of the system by hand, without any machine learning libraries:

  • Built the driving environment, sensors, and collision logic
  • Designed the reward function that scores the car’s actions
  • Implemented a neural network from the ground up, including forward passes, backpropagation, and gradient updates
  • Wrote the full DQN training loop, replay memory, and optimization steps

The result was a small but complete self-driving AI, powered only by algorithms I wrote myself in raw JavaScript.

Link