Genetic Algorithm That Turns Random Two-Wheeled Shapes into Cars

Lecture 2 min.



Открыть на весь экран

The online simulation of the genetic algorithm runs here

Genetic Algorithm That Turns Random Two-Wheeled Shapes into Cars
The program generates vehicles made of wheels and body parts, whose goal is to drive as far as possible. A special algorithm evaluates how far each car gets along the track. The next cars are generated with the previous successful, viable specimens taken into account. They seem to evolve: if in the first generation the specimens without wheels cannot travel even a meter, then by the third generation they start to grow wheels and their shape improves, and by the tenth generation the resulting car is able to cover decent distances.
The genetic algorithm is used to build a car from the Box2D library. The colors show crossover and mutation for each individual in the population. You can choose the mutation rate. Viable models are often generated.
This program uses a genetic algorithm to design a two-dimensional car that will be "optimal" for a particular terrain. The car has two wheels and two loads. The initial positions and radii of these four objects can be chosen by the algorithm. The objects are connected by springs, whose length is also chosen by the algorithm. The loads must never touch the ground.
The optimality of a partial solution (the fitness function) is determined by how long it survives before:
A mass touches the ground. Time runs out. At the start, the algorithm does not even know that the wheels touch the surface. Sometimes you can see various species appear and disappear, for example a "unicycle", especially in the early stages of the algorithm's progress.
Genetic algorithms can converge much faster with a well-chosen fitness function and population size. The developer made the simulation more interesting in terms of visualizing the optimization rather than fast.

See also

See also

created: 2014-09-07
updated: 2026-09-29
887



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Implementation of genetic algorithms"

Terms: Implementation of genetic algorithms