Homework #11
CS 107 - Introduction to Scientific Computation
Homework #11


Due: Wednesday 11/20 at the beginning of class

Object-Oriented Debugging*

In this simulation assignment, you will create a non-grid-based simulation of bugs moving in a constrained area among traps, plotting simulation states, and tracking the population decline.  While significantly different, this assignment is based on the insect trapping research work of John A. Byers:

0. Preparatory Reading: You'll want to feel comfortable with creating arrays of Object, so the Matlab User Guide on Creating Object Arrays is recommended.

1. Bug:  Create a Bug handle class according to these specifications:

2. Trap:  Create a Trap handle class according to these specifications:

3. BugWorld:  Create a BugWorld handle class according to these specifications:

You may find the following sets of test commands helpful.  To visually test the step-by-step simulation:

>> clear
>> w = BugWorld(100, .05, 10, .05);
>> w.tick(); w.plotWorld();
>> w.tick(); w.plotWorld();
... (repeat) ...

One can comment out the plotWorld "cla" command to keep previous Bug positions on the plot. 

To plot the population trend over successive simulations:

>> hold on;
>> w = BugWorld(100, .05, 10, .05);
>> plot(w.ticks(1000))
>> w = BugWorld(100, .05, 10, .05);
>> plot(w.ticks(1000))
... (repeat) ...

*The author understands that the original work concerned flying insects and that "bug" and "insect" are distinct terms, but the pun was just too good to pass up.