🧬 Training the car to do self-parking using a genetic algorithm

Overview

🧬 Self-Parking Car Evolution

Training the car to do self-parking using a genetic algorithm.

Self-Parking Car Evolution

This is an experimental project with the aim to learn the basics of how genetic algorithm works by teaching the cars to do the self-parking. The evolution process is happening directly in the browser. You may check the evolution source-code (in TypeScript) or read the explanation of how it works in my blog-post.

At the beginning of the evolution the generation of cars has random genomes which make them behave something like this:

Self-parking cars at the beginning of the evolution

On the 40th generation the cars start learning what the self-parking is and start getting closer to the parking spot (although hitting the other cars along the way):

Self-parking car in

Another example with a bit more challenging starting point:

Self-parking car in

Genetic Source-Code

The ≈92% of the code in this repository relates to the UI logic (3D simulation of the cars world, form controls for the evolution training process, etc.).

However, the actual code that implements a genetic algorithm takes less than <500 lines of code.

Development Details

The project is a React application written on TypeScript. Styled with BaseWeb.

The 3D world simulation is made with Three.js library using @react-three/fiber wrapper. The physics is simulated with Cannon.js using cannon-es wrapper.

The whole evolution simulation is happening directly in the browser.

To launch the project, fork/clone it and run the following commands:

npm install
npm run start

The website will be available on http://localhost:3000/self-parking-car-evolution.

Hints:

  • You may upload one of the pre-trained checkpoints to avoid starting the evolution from scratch.
  • Use the ?debug=true URL param to see the FPS performance monitor and debugging logs in the console (i.e. http://localhost:3000/self-parking-car-evolution?debug=true).
  • Training progress is being saved to the local storage for each generation (not for each batch/group).
You might also like...
Sorting Algorithm Visualiser using pygame
Sorting Algorithm Visualiser using pygame

SortingVisualiser Sorting Algorithm Visualiser using pygame Features Visualisation of some traditional sorting algorithms like quicksort and bubblesor

A Python Package for Portfolio Optimization using the Critical Line Algorithm

A Python Package for Portfolio Optimization using the Critical Line Algorithm

A tictactoe where you never win, implemented using minimax algorithm
A tictactoe where you never win, implemented using minimax algorithm

Unbeatable_TicTacToe A tictactoe where you never win, implemented using minimax algorithm Requirements Make sure you have the pygame module along with

Exact algorithm for computing two-sided statistical tolerance intervals under a normal distribution assumption using Python.

norm-tol-int Exact algorithm for computing two-sided statistical tolerance intervals under a normal distribution assumption using Python. Methods The

Sign data using symmetric-key algorithm encryption.

Sign data using symmetric-key algorithm encryption. Validate signed data and identify possible validation errors. Uses sha-(1, 224, 256, 385 and 512)/hmac for signature encryption. Custom hash algorithms are allowed. Useful shortcut functions for signing (and validating) dictionaries and URLs.

Algorithm for Cutting Stock Problem using Google OR-Tools. Link to the tool:
Algorithm for Cutting Stock Problem using Google OR-Tools. Link to the tool:

Cutting Stock Problem Cutting Stock Problem (CSP) deals with planning the cutting of items (rods / sheets) from given stock items (which are usually o

A Python program to easily solve the n-queens problem using min-conflicts algorithm

QueensProblem A program to easily solve the n-queens problem using min-conflicts algorithm Performances estimated with a sample of 1000 different rand

Data Model built using Logistic Regression Algorithm on Python.

Logistic-Regression Problem Statement: Your client is a retail banking institution. Term deposits are a major source of income for a bank. A term depo

FingerPy is a algorithm to measure, analyse and monitor heart-beat using only a video of the user's finger on a mobile cellphone camera.
FingerPy is a algorithm to measure, analyse and monitor heart-beat using only a video of the user's finger on a mobile cellphone camera.

FingerPy is a algorithm using python, scipy and fft to measure, analyse and monitor heart-beat using only a video of the user's finger on a m

Comments
  • Component has crashed

    Component has crashed

    Hi,

    I meet the "Component has crashed" error when I open the link "https://trekhleb.dev/blog/2021/self-parking-car-evolution/". The same error occurs when I run the simulator on my local computer by the link "http://localhost:3000/self-parking-car-evolution". Could you please give some comments? Thanks in advance.

    BRs, Zhenyu

    bug 
    opened by bingbingbb 0
Owner
Oleksii Trekhleb
Sr Software Engineer at @uber
Oleksii Trekhleb
A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD.

8QueensGenetic A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD. The project uses the Kivy cross-p

Ahmed Gad 16 Nov 13, 2022
This is an Airport Scheduling Time table implemented using Genetic Algorithm

This is an Airport Scheduling Time table implemented using Genetic Algorithm In this The scheduling is performed on the basisi of that no two Air planes are arriving or departing at the same runway at the same time and day there are total of 4 Airplanes 3 and 3 Runways.

null 1 Jan 6, 2022
N Queen Problem using Genetic Algorithm

The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other.

Mahdi Hassanzadeh 2 Nov 11, 2022
A genetic algorithm written in Python for educational purposes.

Genea: A Genetic Algorithm in Python Genea is a Genetic Algorithm written in Python, for educational purposes. I started writing it for fun, while lea

Dom De Felice 20 Jul 6, 2022
Genetic Algorithm for Robby Robot based on Complexity a Guided Tour by Melanie Mitchell

Robby Robot Genetic Algorithm A Genetic Algorithm based Robby the Robot in Chapter 9 of Melanie Mitchell's book Complexity: A Guided Tour Description

Matthew 2 Dec 1, 2022
Genetic algorithm which evolves aoe2 DE ai scripts

AlphaScripter Use the power of genetic algorithms to evolve AI scripts for Age of Empires II : Definitive Edition. For now this package runs in AOC Us

null 6 Nov 4, 2022
An NUS timetable generator which uses a genetic algorithm to optimise timetables to suit the needs of NUS students.

A timetable optimiser for NUS which uses an evolutionary algorithm to "breed" a timetable suited to your needs.

Nicholas Lee 3 Jan 9, 2022
Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life.

Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life. The algorithm is designed to replicate the natural selection process to carry generation, i.e. survival of the fittest of beings.

Mahdi Hassanzadeh 4 Dec 24, 2022
Using A * search algorithm and GBFS search algorithm to solve the Romanian problem

Romanian-problem-using-Astar-and-GBFS Using A * search algorithm and GBFS search algorithm to solve the Romanian problem Romanian problem: The agent i

Mahdi Hassanzadeh 6 Nov 22, 2022
A fast, pure python implementation of the MuyGPs Gaussian process realization and training algorithm.

Fast implementation of the MuyGPs Gaussian process hyperparameter estimation algorithm MuyGPs is a GP estimation method that affords fast hyperparamet

Lawrence Livermore National Laboratory 13 Dec 2, 2022