This project demonstrates a basic self-driving car simulation built from scratch using JavaScript without any external libraries. The simulation includes car driving mechanics, artificial sensors for environment detection, collision detection, a custom neural network, and a genetic algorithm for evolving the car's driving abilities.
Click the image to watch the video on YouTube.
- Implemented basic physics for acceleration, braking, and turning.
- Simple controls for manual testing and development purposes.
- Each car is equipped with a set of sensors that emit rays in various directions.
- Sensors measure the distance to the nearest obstacle or car, providing crucial data for decision-making.
- Developed a collision detection system that checks for overlaps between the car's bounding box and obstacles or other cars.
- Handles collision response to prevent the car from moving through obstacles.
- Custom-built neural network to process sensor inputs.
- Decides on the car's actions (accelerate, brake, turn) based on sensor data.
- Used a genetic algorithm to evolve the neural network.
- Selects the best-performing cars from each generation, mutates their neural networks, and creates new generations with improved performance.
- A modern web browser (Chrome, Firefox, Safari)
-
Clone the repository:
git clone https://github.com/danfirsten/SelfDriving-Car.git cd selfdriving-car -
No external libraries are required.
- Open
index.htmlin your web browser to start the simulation.
