Programming Assignment:

Interacting Classes

Predator - Prey Model


Purpose

We learn how to modify actions in the model that involve collaboration among different classes



Motivation

Biologists want to study the classic predator-prey model of interaction.  The first instance of this model being studied mathematically, using differential equations, was in a 1920's study of the interaction of fish and sharks in the Mediterranean Sea by Italian mathematicians Lotka and Volterra.

The biologists want to modify the model to have two species, a predator species and a prey species.  The actions of both species will include breeding, but the predator species will not be able to breed unless it has eaten recently.  The predator species will also eat the prey species.  If the predator species does not eat enough, it will die.

Field studies of predator-prey systems, including the study of sharks and fish in the Mediterranean Sea and lynx and hare in parts of northern North America, have shown a cycle behavior where the interdependent populations increase, then decrease in size.  Of course, if the prey species dies out, then the predator, having no food, will also die out.  If the predator species dies out, then the prey will increase in population as much as possible, filling our bounded world.  Biologists want to determine whether the fish simulation model can be modified so that the interacting predator-prey species will exhibit this cyclic behavior.


Download the following files and place them in a folder called PredatorPrey

Create new LJHS project called Predator and store the project in the PredatorPrey folder. Move fish.dat into the PredatorPrey folder. Add all *.cpp files to your project then run the project. If you have warnings with RandGen, remove randGen.cpp from your project. You should get a two-dimensional array display.

Instead of displaying spaces between the fishes in the output, display a dot ('.') for the space. Determine which class needs to be editied and then edit the file so that dots '.''s are output instead of blank spaces.



Specifications of the Model

The basic model works as before with the actions of the fish changed.  There will be two species of fish, one of which is a predator (sharks).  Both species have an age, the number of steps since they were created.  The actions of a predator are as follows:

The actions of a prey are as follows: We note that we will need the following changes to the program: Write a version of the program to implement these changes.  Note:  you will need to be careful that fish that are eaten do not later try to move if they happen to appear later in the list of fish that was passed to the Simulation Step function.  Include appropriate calls to DebugPrint in your new version of the program to help you in debugging the program.

You will have to create your own fish.dat data file. You should have numerous data files to test different situations. Turn in your data file, what you were trying to test for, and the actual results.

What to turn in