Fork me on GitHub

Genetic Algorithm Experience

Let's reach the target!

What is this?

This page is an experimentation built with p5.js allowing the user to manipulate the parameters of a simulation running a genetic algorithm.

In the simulation the robots have the goal to reach the target. First the population of the robots is initialized with a random selection of moves (their "genes"). At the end of each generation each robot reports its distance to the target, and the robots with a distance below the average one are selected to be used to create the next generation.

In the new generation each robot uses a crossover of the genes of the previously selected robots. In addition the genes of each robots "mutate", which means that some of their genes are randomly replaced by new ones. This operation follows the "mutation rate" to know how much randomness should be injected in each generation.

In the next section you will find the different parameters you can manipulate and their description. You will see the results in the section Simulation.

The Charts section shows a history of the generations you run previously and their efficiency.



The number of moves a robot in a generation can do before the generation ends. If the robot crashes before it could do all of its moves the other will continue.
*Modifying this setting resets the simulation

Population size

The number of robots in each generation
*Modifying this setting resets the simulation

Robots size

The size of the robots
*Modifying this setting resets the simulation

Robots in objective

The number of robots which have to reach the target before we consider the objective reached and move the target elsewhere.

Mutation rate

At the end of each generation the robots gets new genes from their ancestors and these genes then mutate. The mutation rate describe which percentage of the genes will mutate.

History size

The number of generations to keep in the charts

Position of the target

At any time you can click anywhere on the simulation to move the target (the black dot).