|
|
Project 3Due Wednesday, March 10, 9pm -- No late assignments will be accepted.Overview This program is a simple simulation of Critters interacting in a world where Critters are born, they eat, they reproduce, and they die. A world something like our own, but somewhat less complicated. Download the distribution file (cse142-proj3-R4F2.zip) and unzip it to the directory where you will be working. There are numerous Critters that can inhabit our BugWorld. The world is initially populated with examples of all the Critters. The user can step the model manually and advance one step at a time (use the 's' key) , or the program can animate, running step after step continuously (use the 'a' key to animate faster, use the 'A' key to animate slower). Every Critter is created with a variety of life characteristics, including life span, reproduction span, maximum calories, calorie burn rate, and maximum strength. As the Critter lives its life, other characteristics are calculated at every step, including age, current calories, and power (max strength scaled by curCalories / maxCalories). At each step, all the creatures get older by one tick and burn their allotted number of calories. If the Critter has lived its life span or has run out of calories, it dies and its remaining calories are spread around to the inhabitants of the neighboring eight cells. If the number of ticks in the reproduction span has passed since birth or the last reproduction event, then a new Critter is created in an empty spot near the original Critter. If none of the eight neighbor cells are empty, the Critter does not reproduce. All the Critters are asked where they would like to go on the next step. They can look at the current occupants of various cells (generally neighbors, but not limited to that), and announce their choice (generally a neighboring or nearby cell, but not limited to that). It is not required that a Critter move at all. For example, the Grass never moves, and the Insects only move if there is a weaker Critter in a neighboring cell. After all Critters have made a selection, they are put in the cell they requested. Mayhem ensues because it's likely that several Critters will want to move to the same spot. Only the most powerful Critter in each cell survives. The calories of all the victims are given to the survivor (up to its maximum) and the process begins again. Class and Interface design Gobbler - The main class of the program. Execution starts here first. BugWorld - Constructs the model and the views. Listens for commands from the keyboard. BugWorldModel - Implements the model and initialization thereof. Extends sim.BasicMatrixModel that does most of the work. BugWorldView - Shows the cells in the matrix Grass, Insect - Sample inhabitants of the MatrixModel. These classes implement the Critter interface. Objects that implement the CritterInfo interface are used to track the relevant life characteristics. GrassFace, InsectFace - Graphic representation of associated Critter. These classes implement the CritterFace interface. The sim package includes all the interfaces and the abstract class BasicMatrixModel. You should not change anything in the sim package, but you are welcome to read the code there. Usage >java Gobble Keyboard commands: s - Single step. Stops animation if it is running. Assignment The goal of this project code is to create and run a world in which a variety of Critters can live their lives together. Individual Critters live and die, but the populations continue. The required part of this homework is to implement two more Critters and add them to the world, as described in this section. There are two major influences on the way a Critter behaves. First, there are several parameters that describe significant characteristics: life span, reproduction span, maximum calories, calorie burn rate, and maximum strength. You set those when you initialize a new Critter object in its constructor. Note that while the Critter exists, the maximum strength value stays the same, but the power value is calculated each step. Power is equal to maximum strength*(curCalories/maxCalories), so if the Critter is very hungry, it is also weaker. When several Critters choose the same cell to jump to, the most powerful one is selected as the survivor. Second, each type of Critter has an algorithm for deciding where to move on the next tick of the clock. This algorithm is implemented in the selectNextCell() method of the Critter. If your selectNextCell() algorithm wants to know about its neighbors it can ask the model about a particular cell, and then use the getCritterInfo() method to find out the current state of the other Critter (if any). See the implementation of Insect for an example of how to do this. The required portion of this assignment is as follows:
In general, the goal of a dynamic environment like this is to have a world in which Critters live and die but none of the populations die out completely. This is very difficult to achieve and is not required, but try to design your Critters so that they don't get completely wiped out early on. You can modify or add new classes in the Gobble directory. Do not modify or turn in any code in the sim directory. Extensions This project can be extended in many ways. You are not required to do any extensions. Some extra credit will be awarded for extensions that go beyond the basic requirements. The scale that will be used for grading the extended project is: * something beyond the basic requirements The list that follows is for your consideration as a source of ideas. Feel free to come up with your own ideas too. You can modify or add new classes in the Gobble directory. Do not modify or turn in any code in the sim directory.
What to turn inUse this online turnin form to turn in the files that make up your project. You should turn in the files that you received from us, either the originals or your modified versions, and the additional files you created. However, do not turn in any of the files in the sim folder. The original versions of those files are already on the turnin server and will be used when your program is compiled.
|