Recently I was reading the excellent Serengeti Rules by Sean B. Carroll, and then this happened.

A few months ago, I wrote the population simulator that I wrote about here, but this purely dealt with so called 'bottom up' regulation - the primarly limiting factor of the population was the amount of food, and an artificial carrying capacity. While reading the Serengeti Rules, it got me thinking about 'top down' regulation - ie, big fish eats little fish, so there are fewer little fish to eat seaweed and other fishy things. I felt that the artifical carrying capacity was just that - artificial - so I set about trying to write a new simulator, which attempts to create a very simple (really simple) model of an ecosystem (more a food web).

Essentially, the model has three numbers - the population of a producer, such as a plant, the population of a primary consumer, such as a rabbit, and the secondary consumer, such as a fox. Each 'cycle' each of these changes - depending on which model I use I can make the producer either increase linearly (which allows both consumers to increase rapidly), be constant (in which case I get a realistic carrying capacity), or change based on a wave pattern (which sort of simulates seasons). This causes changes in the producer. Then, using a ratio of the prey to producers and a random number generator, it is decided whether the prey either reproduce (producer -2, prey +1), stay alive (producer -1, prey +0), or die (producer +0, prey -1). A similar procedure is done on the predators (secondary consumer).

The output of this program being run under different situations is shown below.

No Pred, Const food.
Sim 1; No predators are present, and there is a constant amount of food. The prey population (green) increases and then is relatively stable.


Sim 2; Same as Sim 1, only predators are introduced. While in Sim 1 there was only bottom up regulation, in this one there is top down regulation too - the presence of the predators keeps the prey population at a lower level.
Sim 3; Limited amount of food, small population of prey. No predators. Prey consume all the food, and starve themselves to death.
Sim 4; Prey, predators and large amount of initial food. Small growth rate of food. Initial large amount of food supports a large population of prey, but eventually much food is used up so the prey population slumps. This means there is less pressure on the food so it returns to the original levels.


Sim 5; Initial high concentration of food, so prey peak. Food is regulated by seasons and so when there is lots of food available, more prey are alive so the predator population increases.

This program can be found on my github. It is probably the least taxing of all simulations I have written so far.