A simple self-driving car simulation built completely from scratch — without using any external machine learning libraries.
This project demonstrates how a car can learn to navigate through traffic (obstacles) using a basic Genetic Algorithm, implemented purely from first principles.
- Overview
- How It Works
- Installation
- What Can It Be Used For
- Project Structure
- Contribution
- Acknowledgement
- License
- Author
This project is a first-principles machine learning implementation where:
- A car attempts to drive forward.
- Multiple obstacles (traffic) appear in its path.
- The car learns to avoid obstacles over generations.
- Learning is achieved using a Genetic Algorithm (GA).
- No external ML frameworks or libraries are used.
The goal is to demonstrate:
- Evolution-based learning
- Neural network basics (if implemented)
- Selection, mutation, and crossover
- Fitness-based improvement across generations
This project focuses on understanding how ML works internally, rather than relying on high-level libraries.
- A population of cars is created.
- Each car has its own “brain” (a simple neural model or decision parameters).
- Parameters are randomly initialized.
- All cars attempt to drive forward.
- Sensors (or distance calculations) detect obstacles.
- Based on inputs, cars decide:
- Move forward
- Turn left/right
- Accelerate/brake (if implemented)
Each car is evaluated based on:
- Distance traveled
- Time survived
- Obstacles avoided
Higher survival = higher fitness.
- The best-performing cars are selected.
- Weak performers are removed.
- Selected parents combine parameters.
- Offspring inherit mixed traits.
- Small random changes are introduced.
- Encourages exploration and prevents stagnation.
- New generation starts.
- Over multiple generations, driving improves.
git clone https://github.com/your-username/driving-car-without-driver.git
cd driving-car-without-driveropen index.htmlNo external libraries are required.
This project can be used for:
- Learning Genetic Algorithms from scratch
- Understanding evolutionary computation
- Teaching first-principles machine learning
- Academic mini-projects
- Demonstrating AI concepts without frameworks
- Interview discussions on ML fundamentals
- Classroom demonstrations
├── main.(js/py)
├── car.(js/py)
├── genetic_algorithm.(js/py)
├── environment.(js/py)
├── utils.(js/py)
└── README.md
Contributions are welcome!
To contribute:
-
Fork the repository
-
Create a new branch
git checkout -b feature-name
-
Commit your changes
git commit -m "Added new feature" -
Push to your branch
git push origin feature-name
-
Open a Pull Request
A special thanks to Radu Mariescu-Istodor for the inspiration and project idea. His tutorials and teachings laid the foundation for this project and helped guide its development.
This project is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You may use the code for personal projects or non-commercial purposes. For any commercial use, including reselling or distributing the code, please contact the author for permission.
- GitHub: @Anonav0
- LinkedIn:Swarnavo Khanra
Feel free to reach out with any questions or feedback!
