Project thumbnail

Predator & Prey

22 February 2018
A simulation of species' interaction

This project was an assignment for the programming module at King's College London, for which we used pair programming technique. The aim was to create a visual representation of the animal and plant species' interaction.
Unfortunately, as this was an assignment, I could not publish the code for the project.

Predator & prey – welcome screen
A welcome screen of the simulation program.

We created a simulation with 5 animal species and one plants species.

Predator & prey – beginning of simulation
At the beginning the animals and plants are randomly allocated in the environment.
    We considered many of the real-world characteristics:
  • male and female specimens,
  • ageing of animals and plants,
  • dying due to overcrowding,
  • spread of diseases (sick animals age more quickly),
  • mating only starts at certain age (the babies, obviously, cannot mate),
  • different sleep cycles and
  • weather conditions.

To mimic the real life, we added some factors that highly influence the outcome of the simulation. For example, an animal is ready to breed only if it's old enough, hasn't bred too recently, isn't sick, and, of course, if it isn't hungry. Naturally, only two animals of the opposite genders can mate.

Hunting capabilities and the plants' growth rate are influenced by the weather. If it's sunny the predators have no problems with hunting and the plants are flourishing. However, if the weather is foggy, the predators might have some difficulties seeing their prey.

Predator & prey – end of simulation
At the end of the simulation, some species are missing due to extinction.

We have implemented different kinds of animals in terms of what their food is. We have two species that are only predators (lions and foxes), and two species that are only herbivores (rabbits and deer). Predators' food are other animals, specific to each species, and herbivores' food are plants. We implemented a special species (bears) that simulates the omnivores' behaviour: bears will hunt as well as eat plants.

    Here is a list of all species and their food sources:
  • Rabbits and Deer only eat Plants
  • Lions eat: Rabbits, Foxes and Deer
  • Foxes eat: Rabbits
  • Bears eat: Foxes, Rabbits and Plants

As we can see there are several species that compete for the same food source.

All behaviours in the simulation are randomised which makes the outcome highly unpredictable – but, hey, so is life!