A JavaScript implementation of a self-driving car simulation using Neural Networks, based on freeCodeCamp's Neural Networks and Machine Learning course.
- Neural Network Implementation
Custom neural network from scratch with mutation capabilities - Sensor System
Ray-casting collision detection with road borders and traffic - AI Training
Genetic algorithm implementation with generational evolution - Visualization Tools
Real-time network architecture visualization using HTML5 Canvas - Persistent Storage
Save/load best performing brain models using localStorage
- Vanilla JavaScript (ES6+)
- HTML5 Canvas for rendering
- Web Storage API for model persistence
- RequestAnimationFrame for smooth animations
- Clone repository:
git clone https://github.com/yourusername/Asphyxia- Navigate to project directory:
cd /e:/Download/Documents/Asphyxia/Coding/Artificial Intelligence/Self-Driving- Open index.html in your browser
| Key | Action |
|---|---|
↑ Arrow |
Accelerate |
↓ Arrow |
Brake/Reverse |
← Arrow |
Steer Left |
→ Arrow |
Steer Right |
S |
Save Best Model |
D |
Delete Saved Model |
// Initialize population
const N = 100;
const cars = generateCars(N);
// Load best model
if (localStorage.getItem("bestBrain")) {
cars[0].brain = JSON.parse(localStorage.getItem("bestBrain"));
}
// Mutate other cars
NeuralNetwork.mutate(cars[i].brain, 0.1);Artificial Intelligence/Self-Driving/
├── neural-network/
│ ├── network.js # Neural network core
│ └── visualizer.js # Neural Network Simulation
├── car-system/
│ ├── car.js # Vehicle physics
│ ├── sensor.js # Collision detection
│ └── controls.js # Input handling
├── environment/
│ ├── road.js # Track generation
└── utils/ # Math helpers
MIT License - see LICENSE for details
- Inspired by freeCodeCamp's Machine Learning curriculum
- Vehicle physics model adapted from Realistic Car Driving simulators