Introduction

In the previous article, I introduced a basic simulation where creatures move about eating food. Now I've add some very basic genetics: each creature has a single gene that determines its size (by which I mean area; its radius is the square root of this value). When creatures replicate the child has a 50% chance of getting the same value, a 25% chance of it being one unit bigger, and a 25% chance of it being one unit smaller (unless it is size one already).

Evolution of size over time

I ran the simulation 2 million ticks to give creatures long enough to evolve. The graph below shows how the gene for size changed over time.

Time (1000 ticks) Population size 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 0 50 100 150 200 250 300 350 400 Mean size Food Creatures

The mean size of creatures grew 18 fold over the course of the simulation from 9 to 165. This may come as a surprise since I didn't add a fitness function or any explicit selection. What we have is "natural" selection - larger creatures are more likely to hit food, so are more likely to survive and replicate.

The graph also shows that the average amount of food decreases over the course of the simulation. By the end of the simulation, the mean area of creatures is about 165, making the radius about 12.8. Using the formula from previous article, we can predict the stable amount of food for creatures this big would be about 87, which looks about right.

We need to be a bit careful with this formula, because one of the assumptions we made is that creatures don't overlap and as creatures get bigger, the chance of them overlapping increases to become not insignificant.

Throughout the simulation, the number of creatures is remarkably stable at 50. This is what we'd expect as the number of creatures is purely determined by the rate of metabolism, food energy and rate of food creation, none of which change.

Re-running evolution

In the simulation, creature size increased fairly steadily until it was ~150 at around 1.3M ticks. Then it decreased and didn't recover for another 0.5M ticks. This seemed surprising, so I ran the simulation another three times, this time recording the minimum and maximum size creatures over time.

This chart show three more runs of the simulation. Instead of showing a line for mean creature size, I'm now showing an area for minimum and maximum creature size at each time point.

Time (1000 ticks) Creature size (min to max) 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 0 20 40 60 80 100 120 140 160 180

The three runs are fairly consistent, though there are points where the smallest creature in one run is larger than the largest creature in another. The range of creature size (i.e. the height the area at any given point) looks very consistent within and across runs, at around 10. Two of the runs seem to slow down, and even decrease at a size of ~90, and they all slow down at ~140 - 160.

Exploring mutation rate

One confusion I've seen about evolution is how it can result in organisms becoming better adapted when most mutations have a negative effect. Leaving aside the truth of most mutations having a negative effect, the answer is: selection. Even if most mutations are negative, they are weeded out by the non-random effects of selection.

To explore this idea, I tried a range of mutation effects. In the original simulation, there was a 25% chance of positive mutation (the size increasing) and a 25% chance of a negative mutation (the size decreasing). The remaining 50% of the time the child had the same size as the parent.

I re-ran the simulation three more times. In each case, there was a 50% chance of a neutral mutation (i.e. no change), but the chance of a positive mutation was decreased by 5% and the chance of a negative mutation was increased by 5%.

Positive Neutral Negative 25% 50% 25% 20% 50% 30% 15% 50% 35% 10% 50% 40%

The graph below shows the mean creature size over time for the original simulation and the three new mutation rates.

Time (1000 ticks) Creature size (mean) 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 0 20 40 60 80 100 120 140 160 180 25% 20% 15% 10%

The average creature size bounces around a lot since the population is small so random events can have a big effect. Unsurprisingly, as the chance of positive mutations decreases, the rate at which creature size increases slows. Even when the chance of a positive mutation is 15% (so 35% chance of a negative mutation), the mean creature size increases, though it seems to stop around 40 - 60.

It's not until the chance a positive mutation is 10% (meaning negative mutations are four times more likely), that creature size decreases. It decreases so much that creatures become much less likely to find food and eventually die out. I ran that simulation twice and both times, the population died off after ~400 000 ticks.

Conclusion: The bigger the better?

As evolution simulations go, what we have so far is still pretty uninteresting. We have a single gene and the only selection pressure is for it to increase, so it inevitably increases until the creatures fill the screen. At which point, all food created will be immediately eaten by the first creature and all the others will die.

In the next simulation, we'll look at a more nuanced gene where the selection pressure is more balanced, as it would be in real life.

Further explorations

  • Repeat experiment with different mutation rates multiple times to get an average
  • Graph showing all creature size over time
  • Get some measure of selection pressure and see what affects it