Thu May 25 2023
Self Driving Car Simulation
HTML Canvas
Javascript
Next.js
NEAT Algorithm
An autonomous car simulation that visualizes the behavior of self-driving cars on a road by using custom NEAT algorithm. The simulation includes features like car movement, collision detection, road boundaries, and traffic interaction.
Overview of the project
An autonomous car simulation that visualizes the behavior of self-driving cars on a road by using custom NEAT algorithm. The simulation includes features like car movement, collision detection, road boundaries, and traffic interaction.
Technical Implementation
Neural Network and Genetic Algorithm
The core of this simulation is a custom NEAT-like (NeuroEvolution of Augmenting Topologies) genetic algorithm implemented in JavaScript. This algorithm evolves neural networks controlling the autonomous vehicles.
Key components:
- Neural Network: Input layer (sensor data), hidden layers, output layer (steering, acceleration, braking)
- Genetic Algorithm: Population initialization, fitness evaluation, selection, crossover, mutation
This approach enables cars to improve their driving skills over generations, adapting to the road layout and traffic conditions.
Simulation Environment
Built using HTML5 Canvas and JavaScript within the Next.js framework, the environment consists of:
- Road System: A single, linear road with three lanes
- Car Physics: Basic acceleration, deceleration, and steering
- Sensor System: Virtual sensors detecting road boundaries, other vehicles, and lane positions
- Collision Detection: Simple algorithm for car-to-car and car-to-boundary collisions
- Traffic Generation: Random spawning of additional vehicles at simulation start
Visualization and User Interface
The simulation provides real-time visualization of:
- Car movements and sensor readings
- Neural network structure and activations
- Performance metrics and generation statistics
Users can adjust parameters like mutation rate, population size, and learning rate.
Challenges and Solutions
- Performance Optimization: Implemented efficient collision detection and render optimization
- Balancing Exploration and Exploitation: Used adaptive mutation rates and diverse selection methods
Future Improvements
Potential areas for enhancement include:
- More complex road layouts and traffic scenarios
- Advanced sensor models (e.g., LIDAR simulation)
- Incorporation of reinforcement learning techniques
- Further code optimization for better performance
Conclusion
This Self Driving Car Simulation demonstrates the potential of evolutionary algorithms in autonomous driving systems. By evolving neural networks to navigate a simple road environment, the project provides insights into AI-driven decision-making in traffic scenarios.
The success of this project played a key role in my acceptance to The Knowledge Society (TKS) and its scholarship program, highlighting the impact of hands-on projects in showcasing technical skills and innovation potential.
As the field of autonomous driving continues to evolve, projects like this serve as valuable learning tools and stepping stones towards more advanced simulations and real-world applications.