The Computational Beauty of Nature
Source code

gsw

simulate a three species individual-based ecosystem

Full screen →

gsw -help
  or
gsw    [-width integer] [-height integer] [-steps integer]
       [-seed integer] [-plants integer] [-herbs  integer]
       [-carns  integer]  [-pmin  integer] [-pmax integer]
       [-Ep integer]  [-Eh  integer]  [-Ec  integer]  [-Ch
       integer]  [-Cc  integer] [-Pt integer] [-samp inte-
       ger]  [-stats]  [-pfreq  integer]  [-noext]  [-inv]
       [-mag integer] [-term string]

Simulates an individual-based three-species predator-prey ecosystem according to the specified parameters. The three species consist of plants, herbivores, and carnivores (grass, sheep, and wolves; hence the name, gsw). Updates are done synchronously, and each species has several parameters which can control their life cycles, from the ability to give birth, to the likelihood of starvation. Population statistics of the three species can be calculated over a subset of the entire grid.

The time evolution of an individual-based three species predator-prey ecosystem is simulated according to the specified parameters. The three species consist of plants, herbivores, and carnivores (grass, sheep, and wolves; hence the name GSW). Updates are done synchronously, and each species has several parameters which can control the life cycle, from the ability to give birth, to the likelihood of starvation. Population statistics of the three species can be calculated over a subset of the entire grid.

Miscellany

An interesting change to this code would involve making the the updates asynchronous, which would avoid some subtle deadlock conditions that can occur in how the critters move. Moreover, the motion of the overall system would probably be more "lifelike".

Bugs

No sanity checks are performed to make sure that any of the options make sense.

Options

-widthWidth of the plot in pixels.100
-heightHeight of the plot in pixels.100
-stepsNumber of simulated steps.1000000
-seedRandom seed for initial state.0
-plantsInitial number of plants.5000
-herbsInitial number of herbivores.500
-carnsInitial number of carnivores.50
-pminMinimum plants in vicinity to make new plant.3
-pmaxMaximum allowed plants in vicinity to make new plant.8
-EpEnergy of plant.15
-EhEnergy of herbivore.50
-EcEnergy of carnivore.200
-ChStep energy cost for herbivores.5
-CcStep energy cost for carnivores.5
-PtNumber of steps to grow plant.0
-sampSize of subsample statistaics.-1
-statsShow statistics?True
-pfreqPlot frequency.1
-noextPrevent extinction?True
-invInvert colors?False
-magMagnification factor.1
-termHow to plot points.None

gsw.c on GitHub