Skip to content
cole14 edited this page Sep 4, 2012 · 13 revisions

Here is an overview of the design of the fish tank simulation.

Visualizer

The visualizer will be the graphical interface for the simulation. It will contain the main method, initialize and start the engine, and graphically display the changing state of the fish tank simulation. The visualizer itself will be a thread which spawns the engine and periodically polls it for the current state to display. The main method will spawn the visualization thread and then wait for user input to define how to alter or stop the simulation.

  • implements Runnable
  • main() - Parse any command-line arguments, start the visualization thread, poll for user input to interact with the simulation.
  • draw(State s) - Draw each fish and plant from state 's' to the window.
  • run() - Repeatedly call draw() on the most recent state from the engine.

Engine

The engine will run the fish tank simulation, keep track of statistics, and provide read-only access to the current state.

  • implements Runnable
  • getState() - return read-only state
  • run() - repeatedly calculate next state by looking at each fish's rudder direction and speed, check for collisions, and update statistics

State

The state will store all of the fish in the tank.

  • ArrayList<Fish> - store a list of fish in the tank

Fish

The fish will store its position, rudder direction, and speed, and provide an interface for the AI to set the rudder direction and speed.

  • implements SettableRudderAndSpeed - provides get() and set() methods for rudderDirection and speed
  • position
  • rudderDirection
  • speed

FishAi

The fish AI will be associated with a particular fish through the SettableRudderAndSpeed interface, and constantly be updating its rudder direction and speed by analyzing the state from Engine.getState().

  • implements Runnable
  • run() - constantly updating rudder direction and speed to obtain food
Clone this wiki locally