The goal of this lab is to experiment with a biological simulator, in particular how polymorphism is useful in its design.
As in previous assignments, move into your cs235
directory.
Make a directory for this assignment, and change into it.
cd cs235 mkdir lab10 cd lab10
The files for the simulation are in a special directory in the course public directory. Copy all of these.
cp /homeemp/tvandrun/pub/235/simulation/* .
You have already seen demonstrated the basic use of this program.
I have made one notable change since class on Friday:
Now the fox's weight increase when eating a rabbit depends on the weight
of the rabbit.
So, when a fox eats a 3-unit rabbit, it gains 3 units, but if it eats a
5-unit rabbit it gains 5 units.
Consequently, every agent has a weight()
method.
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.
Currently, the code is set up to use the GUI viewer, but you may change it
to the text viewer if you prefer.
If you use the GUI viewer, the size -height 30 -width 60
works best; for the text viewer, simply experiment until you find
dimensions that fit a big enough window.
To specify an initial population of clover, rabbits, and foxes,
use -clover 100
etc.
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.
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:
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 simulator, 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?
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.
You will turn this project in electronically, by emailing it to Joe. Since this consists in several files, use the following command to package them into a single file:
tar cvf somefilename.tar *
The command tar
is short for "tape archive",
which doesn't make much sense any more; it goes back to a time in
computer history when tapes were used for information storage.
What it does is make an "archive" file (in this case a "tar file", or, as it's
sometimes called, a "tar ball").
The argument cvf
is a code to specify what this
command should do, in this case create a new archive (as opposed
to adding stuff to an old one or extracting stuff from one),
be verbose about what's going on (so it displays messages to
the screen about what it's doing), and specify the file
by name (as opposed to the default file).
somefilename.tar
is the name of the archive file it's
creating (feel free to use a different name).
*
indicates you are archiving all the files in the directory.
This should include your report.
Then email the tar file to Joe.R.Michalka@wheaton.edu.