Predator-Prey Agent Model

(Description at the bottom)

Key:
Predator
Prey
Time steps elapsed:
Frames per second:
Number of rows:
Number of columns:
Cell width (pixels):
Cell height (pixels):
Initial number of predators:
Initial number of prey:
Amount of food to regrow per cell per time step:

Model Description

Initial State

In a rectangular world, there are cells and two types of agents: predators and prey. Initially, and each time the model is reset, the world is created by filling each cell with the maximum amount of food. A certain number of predators and prey are randomly placed in the cells with a certain amount of food initially in their bellies. At no point during the simulation can two agents occupy the same cell. The state of the model is initially drawn on the screen.

During Each Time Step

During each time step of the simulation,

  1. each cell regrows food by a certain amount;
  2. each predator, if it is hungry, looks for prey in the 4 nearest-neighboring cells. If it finds one, it eats it;
  3. each surviving prey, if it is hungry, eats food from the cell it occupies;
  4. each agent looks for another agent of its own species in its 4 nearest-neighboring cells, and if it finds one, both agents have not reproduced yet in this time step, both are both old enough, there is an open cell next to the agent that was looking (in one of its 4 nearest-neighboring cells), and with some percent chance, then they reproduce to create a new agent with a certain amount of food in their belly and placed in one of the empty nearest-neighboring cells next to the agent that was looking;
  5. all agents move randomly to one of their empty, nearest-neighboring cells;
  6. all agent get hungry and lose a certain amount of the food in their bellies, whereby if they have no food left in their bellies they die of starvation;
  7. all agents get older, and if they are too old they die of old age; and finally
  8. the current state of the model is drawn on the screen.

Final State

The simulation runs indefinitely, until the stop button is clicked.

© Shodor 2017