Skip to content
Trekhleb.dev·

🚗Car Learns Self-Parking in 40 Generations Using Genetic Algorithm

Teaching a car to park itself with AI in 40 tries

TL;DR

A car trained to self-park using a genetic algorithm in TypeScript. It evolves over 40 generations, with a simple brain function and 8 distance sensors. Users can tweak the genetic parameters and see the results.

A car is learning to self-park using a genetic algorithm implemented in TypeScript. Over 40 generations, the car evolves its parking skills, with a brain function based on a linear polynomial. This method is simple but limits the car's ability to learn complex maneuvers. The car has 8 distance sensors and 2 types of muscles, controlled by signals from the brain every 100ms. Users can train the car from scratch and see it in action. This project showcases the basics of genetic algorithms and their potential in robotics.

Car Learns Self-Parking in 40 Generations Using Genetic Algorithm — Trekhleb.dev

Key Points

1

Car evolves over 40 generations to learn self-parking using genetic algorithm.

2

Brain function uses linear polynomial with 8 sensor values and 9 coefficients.

3

Car has 8 distance sensors detecting obstacles within 0-4m range.

4

Muscles receive signals from brain every 100ms with values of -1, 0, or +1.

5

Simulator allows users to train cars and see results in real-time.

Why It Matters

If you're working on robotics or AI projects, this genetic algorithm approach offers a simple yet effective way to evolve systems. The car's brain function, based on a linear polynomial, demonstrates how basic algorithms can still achieve complex tasks. However, the trade-off is a lack of sophistication in learned behaviors. This project is a great starting point for understanding genetic algorithms in practical applications.

genetic algorithmself-parkingroboticstypescriptai

Comments

Subscribe to join the conversation...

Be the first to comment

Enjoyed this article?

Get it daily. 7am. Free. Reads in 5 minutes.

Also get