Lab 9: Predator/Prey Simulation

The goal of this lab is to experiment with a biological simulator, in particular how polymorphism is useful in its design.

1. Setup and introduction

As in previous assignments, move into your cs235 directory. Make a directory for this assignment, and change into it.

mkdir lab9
cd lab9

The files for the simulation are in a special directory in the course public directory. Copy all of these.

cp -r /homes/tvandrun/Public/cs235/lab9/* .

The -r part means that one of the things you're copying is a directory. If you do ls, you'll see an item simulation, which is a directory containing the source code for the simulation package, which contains the grid and windows. You will not need modify any of this, but you may look at it if you're curious.

2. Initial experiments

You have already seen a demonstration the basic use of this program. The first thing you should do is glance over the code to re-familiarize yourself with it. Then compile PredPrey.java, and run the simulation. You can select between a small view, big view, or medium split-screen view by using the -small, -big, and -medium flags, for example

java PredPrey -big &

Try running the simulation with various initial populations. If you observe that either foxes or rabbits have a particular advantage (say, foxes always eat all the rabbits before the rabbits eat all the clover, or if clover always becomes extinct), then you can adjust the growth rate, speed, and visual acuity of one or more species to try to put them on more equal footing. Try to find an initial setup where you cannot predict the outcome--- where the outcome partially depends on the random placement and movement on the agents; for example, you might find that with 100 clover, 20 rabbits, and 5 foxes, sometimes the rabbits will become extinct, and other times the clover becomes extinct. Make observations about the patterns of behavior.

3. Experimental changes

Now you and your partner should think about what major changes you would like to make to the system to make it more interesting. Some obvious directions include the following:

Some ideas that students have come up with in the fast:

When you have an idea, talk to me first so I can help you refine it and point you in the right direction on how to implement it.

As you try out your modified simulation, look for patterns of behavior. What parts seem to be realistic in modeling the real world? Can you make the system stable (no species becoming extinct, at least for a long time), or can you at least find a starting configuration where the results are unpredictable?

4. Report

Along with the code you wrote or modified, for this lab you should turn in a short report (a few paragraphs long). Talk about what you initially observed in the simulation before you modified it; what you wanted to change to make the simulation more realistic or interesting; what changes you made (including an explanation of the implementation and references to what part of the code you modified); and what you observed when running your new version of the simulation. You may write the report in a textfile.

5. Turn-in

Turn in a hard copy of your report. Indicate which account you are using. We will grade your code by logging into the appropriate lab account and looking at it.


Thomas VanDrunen
Last modified: Tue Oct 28 08:14:19 CDT 2008