CS 231: Assignment #8

Life and Death in the Broccolengeti

The purpose of this week is to combine it all in one big simulation: agents, resources, obstacles, life, and death. We're going to resurrect the Broccoli fiend simulation and then take some measurements of the macro characteristics as the simulation progresses.

This will be the last Simulation given to you. Next week you'll have a two week project where you get to choose what to simulate (we'll provide some choices).

Documentation for Java 1.5 is located at: Java 1.5 SE API.

Documentation for Java 1.6 is located at: Java 1.6 SE API

Problem Description

Re-implement the Broccoli Fiend simulation in the general framework. The simulation should have the following characteristics.


The purpose of this simulation is to generate a number of plots showing the effects of changes in the simulation parameters.

  1. Initialize the simulation with N agents and 4N broccoli resources, all randomly distributed. What is the pattern of the simulation? Track the number of Broccoli Fiend agents and the overall amount of broccoli available. Show these plots superimposed. [Hint, you may want to override the Iterate function in the parent Simulation in order to make calculations that are Agent/Resource specific. You can use super.Iterate() to call the parent method and then run through the data to get what you need.
  2. Track the number of Broccoli Fiends over time. What is the carrying capacity of the landscape? Try initializing it with 3N and 5N broccoli plants. Come up with metabolism and vision ranges that provide for reasonably stable simulations.
  3. With the N/4N ratio, track the average metabolism and average vision of the population over time. Each iteration, write the number of agents, average metabolism, average vision, and amount of broccoli available on the Landscape out to a file. If you write the data for each iteration as a separate line and put commas between the numbers, you can read the file directly into Excel and generate simple graphs.


  1. Implement an obstacle class that does not let an agent cross it. Then do something like have two parts of your simulation with different amounts of broccoli and see if different kinds of agents result. Look up the term punctuated equilibrium with respect to evolution.
  2. Color your Broccoli Fiend agents so that the color indicates how hungry they are.
  3. Explore the ranges of metabolism, broccoli regrowth, and vision and see what happens.


Make your writeup for the project a wiki page in your personal space. If you have questions about making a wiki page, stop by my office or ask in lab.

Your writeup should have a simple format.

Once you have written up your assignment, give the page the label:


You can give any page a label when you're editing it using the label field at the bottom of the page.

Do not put code on your writeup page or anywhere it can be publicly accessed. To hand in code, please put it on the Academics server in your folder within the COMP/CS231 directory.