Last edited 08dec10 by

Predprey: A Predator Prey Cellular Automaton


This program is a cellular automaton created using Python and OpenGL. The predators are denoted by red cells and the prey are denoted by green cells.

The automaton in action!

Making the Program

This program is an example of a three state cellular automaton. The states being predator, prey, or empty. The beauty of a cellular automaton is that the program just has to have a common set of rules for each cell. Still, it can show very interesting macro phenomena.

In my first program, the rules were determined by the number of predators or prey in each cells von Neumann neighborhood. It turned out that this didn't allow for enough variation in the rules and always resulted in either a predatorial extinction, or a prey extinction follewed by a predatorial extinction.

The second program worked to fix these problems, The rules for each cell were now determined by the moore neighborhood, which consists of all eight cells around the cell. This allowed for more variation in the rules for the next generation. Thus, I was able to find a set of rules that allow for a continuous predator prey equilibrium.


1. My first program explores how the numbers of predators and prey behave without an overpopulation factor.
2. The second program explores how the number of predator and prey behaves when there is an overpopulation factor on the prey.


To see a program where the system reaches an equilibrium with the prey dying and the predators quickly following click here.

To view a program where only the predators go extinct and the prey live forever click here There are two examples with the steady state solution to the cellular automaton when both species live forever: program without overpopulation and my program with overpopulation.

If you would like to make a cellular automaton of your own click here.
To view my powerpoint presentation click here.
To see my full report in LaTex click here.
To use these programs, right click on the link and click save as. You need Python and OpenGL to run the program.
To view the code for the program left click on the link.

Thank you to Professor George Francis.