Genetic Algorithms

Population: The population of fish is randomly generated with random values for their DNA. The genotype of a fish consists basically on 2 variables (mass and hue), which then produce the phenotype of the fish (color, size, max speed, range of view, maturity threshold, bite size, etc).

Selection: Fish are born with a certain amount of energy that they will spend to move (swim), when they run out of it they die. They can eat food to gain energy, and also they can eat other fish that are smaller than them (less than half of their mass). The more energy they can collect, the longer they will live.

Reproduction: Agents can spawn offsprings, they have to reach a certain age (it varies depending on the mass of the fish), once they do, they are able to mate, therefore perpetuating their genes. When they mate, the fertility threshold is increased again, and if the fish collects enough food to live longer it can mate several times, but the older the fish gets the more energy consumes to swim, so in the end every fish dies.

Crossover and Mutation: The offsprings are a crossover of the genes of their parents (if one parent is big and the other one is small, the child will be medium sized, if one is red and the other one is blue, the child will be purple), but a really small fraction of the offsprings get mutated genes, introducing new features to the population.