The Notebook.

A bunch of possibly interesting things.

Inheritance/Population Simulation.

The population reaches a stable position which is just below the max capacity.

Over the past few weeks I have been considering trying to write a sort of population simulator - ie, you have a sample of say 100 individuals (very basic individuals) and you let it run. They have some genes (currently the code has two, but it could be expanded) and these genes affect how long they live, how sexually mature they become, basically how likely they are to pass on their genetics. It would therefore show a sort of selection, and because of this would also show a population maximum.

This weekend I decided to finally start writing this, and so far it is going well. It currently has a hard set population maximum (5,000, but it can be changed in the code), however I am planning on changing this so it has a set amount of food in the environment, and as individuals grow they take up more food depending on their gene code, and then when they die this food (- some which cannot be released) is given back into the environment. If the food runs out, some organisms may have an ability to survive without, but others won't - so they will die out but the survivors will have more food.

At the moment, it creates 100 individuals with two random genes - x and y - which determine their survival characteristics. Currently it is based around the following equations;

age_{max} = 2000|sin(\frac{x}{10}) \cdot cos(\frac{y}{10})|

age_{spread} = 1000|sin(\frac{y}{10}) \cdot cos(\frac{x}{10})|

This means that as the x and y values change, the maximum age and spread change - so certain configurations will be more stable than others. The probability of reproduction is modeled as a normal distribution using;

\frac{1}{spread\cdot \sqrt{2\pi}} e^{-\frac{(age - \frac{age_{max}}{2})^{2}}{2\cdot age_{spread}^2}}

This gives a probability of reproduction, so the survival is sort of down to chance. If an individual reproduces then their genes change as they are passed on (only slightly) so the most successful genes are likely to survive. At the moment (without the food construct) individuals die at their maximum age multiplied by a factor which is dependent on the number of individuals in the population;

age_{relmax} = age_{max} * (1-\frac{pop^3}{pop_{max}^3})

So, as the number of individuals increases, the age at which individuals dies gets smaller - so in the graphs we see a boom bust population change, as when it gets too big individuals die, and when it gets too low they live longer.

Hopefully this new project will continue to grow. For now, the source is on github, and an image of the program is shown below.


The population reaches a stable position which is just below the max capacity.

The population reaches a stable position which is just below the max capacity.