-
Notifications
You must be signed in to change notification settings - Fork 2
Design
Here is an overview of the design of the fish tank simulation.
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.
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
The state will store all of the fish in the tank.
-
ArrayList<Fish>
- store a list of fish in the tank
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
- providesget()
andset()
methods forrudderDirection
andspeed
position
rudderDirection
speed
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