Fork me on GitHub WHAT IS THIS?
Autonomous Agents

Limited ability to perceive the environment: Every fish can only see things (other fish and food) within a restricted range.

Process information from environment and compute an action: In this case the actions are computed as forces (vectors). If the environment tells the fish that there's a huge scary fish ahead, the action will be a force in the oposite direction, or if the fish sees food, a force will pull it towards it. There are social behaviors like shoaling/schooling that come from basic separation, alignment and cohesion forces. There are also evolutionary strategies, like the affinity for other fishes of a similar color, promoting the generation of different races. All these forces are added-up at every time-step and result making the fish decide in which direction to swim.

No leader: The fishes are not commanded by a leader to display complex behaviors like shoaling/schooling , this intelligent and structured dynamics emerge from local interactions from the agents themselves.

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.

click anywhere to enter behaviour inspector