Agent-Based Models

Agent-based models simulate a system as a network of interacting agents within an environment. At a minimum, an agent has the following properties:

  • state
  • neighbourhood (e.g. grid/lattice, or network)
  • interaction functions: agent-agent or agent-environment

Agents are used to model a wide variety of real-world phenomena, including ecosystems, disease spread, and social interactions. Limor Raviv and Bill Thompson have a tutorial on agent-based modeling using Python which demonstrates the evolution of language in populations.

Rabbits and Foxes

For this session, we’ll also look at an agent-based simulation of a simple ecosystem containing three different kinds of organisms: grass, rabbits, and foxes. Agents move over a grid of discrete locations, each containing some grass and at most one animal. Each of these organisms behaves according to a simple set of rules.

Grass grows at every location where an animal is not present.

Rabbits move randomly to empty locations and eat grass.

Foxes move randomly, preferentially moving to neighbouring locations where there are rabbits and eating them.

Animals (both rabbits and foxes) reproduce whenever they are not hungry.

The locations in the world are laid out on a Cartesian grid. Each location has an x and a y coordinate, and eight neighbouring locations, which are those locations with x and y coordinates that differ by no more than 1.

Periodic Boundary Conditions

The world has periodic boundary conditions, which means that if an animal moves off the right-hand edge of the grid (x == WORLD_SIZE), it reappears on the left-hand edge (x == 0) and vice-versa, and if an animal moves off the bottom edge of the grid (y == WORLD_SIZE), it reappears on the bottom edge (y == 0) and vice-versa. The boundary conditions are shown for an example 5x4 grid in the diagram below; for example, location 15 has neighbouring locations {14,10,11,19,16,4,0,1}. diagram of periodic boundary conditions

Updated:    18 Nov 2022 / Responsible Officer:    Director, School of Computing / Page Contact:    Josh Milthorpe / License:    CC BY-NC-SA 4.0