Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Predator-Prey Simulation

This is a feature-rich 2D predator-prey simulation implemented in C++ using SFML (Simple and Fast Multimedia Library). The simulation takes place on a 20 x 20 grid, where ants (prey) and doodlebugs (predators) interact in a dynamic ecosystem.

Explore the fascinating interplay between predators and prey in this simulation, where OOP principles such as inheritance and polymorphism contribute to a modular and extensible code structure.

Features

  • Ant Behavior:

    • Random movement in up, down, left, or right directions.
    • Breeding after surviving for three time steps.
    • Breeding results in a new ant in an adjacent empty cell.
  • Doodlebug Behavior:

    • Moves to an adjacent cell containing an ant and eats it.
    • If no ants nearby, moves randomly like ants.
    • Breeds after surviving for eight time steps.
    • Starves and dies if it hasn't eaten an ant within three-time steps.
  • Simulation Dynamics:

    • Initialization with 5 doodlebugs and 100 ants randomly placed.
    • Time steps simulate the movement, breeding, and starvation of critters.
    • Displayed using SFML, with green circles representing ants and red circles representing doodlebugs.

About

A 2D predator-prey simulation using C++ and SFML, implementing object-oriented principles to model the dynamic interactions between ants and doodlebugs.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages