https://github.com/lcary/doodlebug
Two-dimensional predator-prey simulation in C++
https://github.com/lcary/doodlebug
matrix predator-prey simulation two-dimensional
Last synced: 6 months ago
JSON representation
Two-dimensional predator-prey simulation in C++
- Host: GitHub
- URL: https://github.com/lcary/doodlebug
- Owner: lcary
- License: mit
- Created: 2017-11-07T00:21:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-14T18:20:05.000Z (almost 8 years ago)
- Last Synced: 2025-02-14T07:46:55.505Z (8 months ago)
- Topics: matrix, predator-prey, simulation, two-dimensional
- Language: C++
- Homepage:
- Size: 222 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
doodlebug
=========Project inspired by Walter Savitch's 2014 C++ textbook. This program
essentially answers Chapter 16, Question #9 of
_Problem Solving with C++_ (ninth edition).Overview
--------The goal for this project is to create a simple two-dimensional
predator-prey simulation. In this simulation the prey are ants
and the predators are doodlebugs. These critters live in a world
composed of a 2D grid of cells. Only one critter may occupy
a cell at a time. The grid is enclosed, so a critter is not
allowed to move off the edges of the world. Time is simulated in
time steps. Each critter performs some action every time step.
You should see a cyclical pattern between the population of
predators and prey, although random perturbations may lead
to the elimination of one or both species.Usage
-----Run `make run` to build and run the C++ program, starting the
simulation.% make run
Grid created.
Creating organisms...
total # of doodlebugs: 5
total # of ants: 100
o - - - o - - - - o - - - - - o o - o -
- - o o - - - - - - - X - - - - o - - -
- o o - - - - - - - - - o o o - - o - -
- o o - o - - - o - - - - - o - - - - o
o o - - - - - o - - - - o - - - - - - -
o o - X X - - - - - o - o - - o o - o -
- - o - - - - o - - o o - - o - - - o -
o - - - - - - - - - - - - - o - - - - o
- - - o - - - - - o - - - - - - - - - -
- - - - - - - - o - - o - - - - - - - -
- - o - - o - - - o o - - - - o - o o o
- - - - - o - - - - - - - o - - - o o o
- - - - - - o - o - - - o - o - - - - -
o - - - - - - o o - - - o X - - o - - -
o - o - o - - - - - - - - - - o - - o -
- - - o - - - - - o o o o o o o - o - o
- o - - - - - - - - - - o - - - o - - -
- - - - - - - - - - - - o - - o - - - o
o o - o - o o - o - - - - o - - X o o -
- o - - - o - o - - - - - - - - - - - -...
Graph
-----Run `make graph` to show a graph of the organism counts over a
given number of iterations.