A stunning self-driving car simulation built entirely with vanilla JavaScript, HTML, and CSS - no external libraries required!
- 🧠 Neural Network AI - Self-learning car behavior
- 🛣️ Dynamic Road Generation - Procedural road layouts
- 🚦 Traffic Simulation - Realistic traffic patterns
- 🎮 Interactive Controls - Manual override capabilities
- 📊 Real-time Visualization - Neural network decision making
- 🎨 Smooth Animations - CSS-powered visual effects
- 📱 Responsive Design - Works on desktop and mobile
-
Clone the repository
git clone https://github.com/NotSujanSharma/self-driving-car.git cd self-driving-car -
Open in browser
# use python server or any other server to start a local server python3 -m http.server -
Start driving!
- Watch the AI learn to navigate traffic
- Use arrow keys for manual control
- Adjust AI parameters in real-time
| Key | Action |
|---|---|
↑ |
Accelerate |
↓ |
Brake/Reverse |
← |
Turn Left |
→ |
Turn Right |
Space |
Delete Brain and Reset Simulation |
R |
Reset Simulation |
S |
Save Best Brain |
The self-driving car uses a neural network to make driving decisions:
- Sensors - Ray casting for obstacle detection
- Neural Network - Processes sensor data
- Decision Making - Outputs steering and acceleration
- Learning - Genetic algorithm for improvement
Sensors → Neural Network → Controls → Car Movement
↑ ↓
└─── Feedback Loop ←────────┘
- Frontend: Vanilla JavaScript (ES6+)
- Styling: Pure CSS3 with animations
- Canvas: HTML5 Canvas for rendering
- AI: Custom neural network implementation
- No Dependencies: 100% library-free!
self-driving-car/
├── css
│ ├── style.css # Main styles
├── img
│ ├── car.png # Car image
├── js
│ ├── main.js # Main entry point
│ ├── car.js # Car physics
│ ├── controls.js # Controls
│ ├── network.js # Neural network implementation
│ ├── sensor.js # Sensor system
│ ├── road.js # Road generation
│ ├── visualizer.js # Neural network visualization
│ └── utils.js # Utility functions
└── index.html # Main HTML file
This project is licensed under the MIT License - see the LICENSE file for details.
Sujan Sharma (@NotSujanSharma)
- 🌐 Website: https://sujan.brokenai.ca
- 📧 Email: sujan@brokenai.ca
- 🐦 Twitter: @CheaterPeter0
- Inspired by modern autonomous vehicle technology
- Built with passion for AI and web development
- Thanks to the open-source community for inspiration
If you found this project helpful or interesting, please consider giving it a star! ⭐