Natural Selection Simulation


This is a program that simulates natural selection and evolution. The gray square is the environment. The blue dots are food, which regenerates at a constant rate. The small moving circles are the organisms. The organisms are constantly moving, and they lose energy as they move. If they run out of energy, they die. As they start to get hungry, they will turn yellow, then red as they are starving. They can gain energy by eating the food.

The pink circle is the vision of the organisms. They can see any food inside that circle, and they will move to the closest food they see. They will eat the food once they are close enough. If they cannot see any food, they will turn randomly, and they will turn around when they hit the edge of the environment.

If an organism has enough energy, it can breed. Breeding occurs when two organisms with enough energy to breed get close to each other. A new organism will be created, and its starting energy will be subtracted from that of the parents. The parents will then move in a random direction for about 1.5 seconds, in order to give the baby a chance at finding food and surviving.

When two organisms breed, the traits of the baby are somewhere between those of the parents. However, there is about a 10% chance that a trait will have a mutation, which will sometimes move value of the trait to somewhere just outside the range of the parents.

There are six different traits that can change between organisms. They are:

You can see the current averages of these statistics by pressing 's'.

The source code for this page can be found here.