CIT 591 Assignment 13: Wator
Fall 2014, David Matuszek

Purposes of this assignment

General idea of the assignment

"Wator" is a classic predator-prey simulation. It takes place in a "water world," populated by sharks and fish.

In our version, the world ocean is represented by a toroidal array--that is, each edge is connected to the opposite edge (left to right, top to bottom), so that there are no "edges" to the world.

Simulation takes place in a series of "steps." At each step, each fish and each shark will have the opportunity to do something--starve, eat, move, or reproduce. In more detail:

  Sharks Fish
Starve Sharks can only go so long (a certain number of steps) between meals. If they have not eaten in that number of steps, they starve, and disappear from the array. Fish eat algae and seaweed, which are always present, so fish never starve.
Move Each shark chooses a random direction (left, right, up, or down) and tries to move in that direction. The move is possible if there is only water in that direction, or if there is a fish in that direction, in which case it eats the fish. If the adjacent location in the chosen direction contains another shark, the shark cannot move.

Sharks do not "look around" and choose a good direction. Nor do they try again this step if the chosen direction is blocked.
Each fish chooses a random direction (left, right, up, or down) and tries to move in that direction. The move is possible if there is only water in that direction; it cannot move if the adjacent location in that direction contains a shark or another fish..

Fish do not "look around" and choose a good direction. Nor do they try again this step if the chosen direction is blocked.
Eat If a shark moves into a location containing a fish, it eats that fish, and becomes "full"--that is, its time to starvation is reset to some maximum value. Eating additional fish cannot increase its time to starvation beyond that maximum. Fish eat algae and seaweed, which are always present, so fish never starve.
Reproduce After a certain number of steps, sharks try to reproduce. They accomplish this by moving, and leaving a new shark in the location they just vacated. If a shark cannot move when it is time to reproduce, it will reproduce the next time it can move (assuming it does not starve to death first). After reproduction, the time to reproduce is reset for both the parent and the newborn shark. The newborn shark is "full," that is, set to the maximum number of steps before starvation. After a certain number of steps, fish try to reproduce. They accomplish this by moving, and leaving a new fish in the location they just vacated. If a fish cannot move when it is time to reproduce, it will reproduce the next time it can move. After reproduction, the time to reproduce is reset for both the parent and the newborn fish.

These parameters can be set in the GUI:

  • Initial number of sharks
  • Number of steps a shark can survive between meals
  • Number of steps until a shark tries to reproduce
  • Initial number of fish
  • Number of steps until a fish tries to reproduce
  • Speed of the simulation

Details

This program has been written and partially debugged, and is present on Github. The simulation and display work, but the fish and sharks do not behave properly. There are basically three parts to your task:

This assignment is all about reading and debugging someone else's code. You will find things in the code that you haven't seen before and may not understand. Some of these things you will need to figure out in order to complete the assignment; many you will not need to understand. That's okay. You may also find errors of a sort not covered above, in which case you should fix those also.

Wator uses the Model-View-Controller design pattern. The Wator class (the GUI) is the controller; The Display class is the view; and all the other classes constitute the model. The Ocean class is the "main" model class, in the sense that it controls the activities of all the other classes comprising the model.

Due date

Turn your assignment in to Canvas before 6am Wednesday, December 10.