Skip to content

Class List

Transfinity edited this page Sep 21, 2012 · 7 revisions

https://docs.google.com/document/d/1zEqH9PrgFO5gD9Hc2Xr8oeAPqGzNfdJQCWXDanV2WPw/edit

Package: Environment

Class: Engine implements Runnable

Continuously processes the environment, updates the game state.

  • private State backState
  • private State frontState
  • getState(long ID) - Waits until the current engine state’s ID is > ‘ID’ and returns the new state. (busy waiting)

Class: State

Represents the game state

  • ArrayList<Drawable>

Enum: FishCode

Magic global numbers:

  • OK
  • DEAD
  • TOO_SMALL
  • TOO_HUNGRY
  • OUT_OF_BOUNDS
  • COLLISION

Class: Fish implements Drawable

Represents a fish. The engine will continuously loop through fish, updating information after sanity checking and making it available to the visualizer/FishAIs

  • public int setDirection(double rads) - returns an error code if dead, out of bounds, etc
  • public int setSpeed(double rods/hr) - returns an error code if dead, out of bounds, etc
  • public int eat() - returns an error code if dead, nothing to eat, too small, etc
  • public int reproduce() - returns an error code if dead, not enough nutrients, no space, etc
  • public getXYZ()
  • public isAlive()
  • protected setXYZ()
  • protected setAlive()
  • protected boolean isAlive
  • protected int size
  • protected int nutrients

Package: AI (maybe rename this if we want a human-controllable FishAI)

Class: FishAI implements Runnable

Retrieves environment state data and sets Fish acting states.

  • ArrayList<Fish>

Package: Default

interface Drawable

Represents anything that can be drawn on the screen

  • public BufferedImage getPNG() - tell the visualizer what you look like

Class: Visualizer extends JFrame implements Runnable

Repeatedly draws the fish tank by calling getState(iD) from the engine, which blocks until a new state is available.

  • private State state - store the state for drawing
  • public void run() - update current state then repaint()
  • public void paint() - draw all objects in the state to the screen