Search code examples
algorithmcollision-detectionsimulationagentagent-based-modeling

Predator-prey simulation


I'm trying to implement a model of predator-prey. It is agent-based model. Every few milliseconds is a new move. On the field there are two types of creatures: predator and prey. The behavior of each of them is given by the following rules:

Prey:

  1. Just moved to an unoccupied cell
  2. Every few steps creates offspring to his old cell
  3. Life expectancy is limited by the number of moves

Predator:

  1. Predator moves to the cell with prey. If such cells are not, in any free neighboring cell
  2. Same
  3. Same

I have a problem with the choice of prey move. Prey

For example, I have preys in cells 5 and 9. Each of them can move to cell 6. How can I resolve this conflict? Thanks


Solution

  • Use asynchronous updating. Iterate through the prey in random order, having them decide in turn to which cell they should move.

    This is a common approach in simulations. It has an additional benefit in that it eliminates limit cycles in the dynamics.