Class Simulation

java.lang.Object
  extended bySimulation
Direct Known Subclasses:
BirdSimulation, CrowdSimulation, DESimulation, DiseaseSimulation, DSSimulation, PoliticalSimulation, WDSimulation

public class Simulation
extends Object

Class that implements a general Simulation


Field Summary
protected  LinkedList agents
          Linked lists for tracking all agents in the simulationh
 FrameSequence frames
          FrameSequence in case the user wants an animation
 BufferedWriter output
          A BufferedWriter for writing to
protected  World world
          World that the simulation runs
 
Constructor Summary
Simulation()
          Constructor to set output to null
 
Method Summary
 void add(Agent newOne)
          Add this actor to the agents list
 void closeFile()
          close the file and clear the output stream
 void endStep(int t)
          End of step processing
 LinkedList getAgents()
          Accessor for all agents
 String lineForFile()
          lineForFile -- string to write to file on each timeStep.
 void openFile(String filename)
          Open the input file and set the BufferedWriter to speak to it.
 void openFrames(String dir)
          Open a frame sequence at the given directory
 void remove(Agent newOne)
          Remove this actor from the agents list
 void run()
          Run for a default of 50 steps
 void run(int timeRange)
          Ask all agents to run for the number of input steps
 void setUp()
          setUp the simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agents

protected LinkedList agents
Linked lists for tracking all agents in the simulationh


world

protected World world
World that the simulation runs


output

public BufferedWriter output
A BufferedWriter for writing to


frames

public FrameSequence frames
FrameSequence in case the user wants an animation

Constructor Detail

Simulation

public Simulation()
Constructor to set output to null

Method Detail

getAgents

public LinkedList getAgents()
Accessor for all agents


add

public void add(Agent newOne)
Add this actor to the agents list

Parameters:
newOne - agent to add to the list

remove

public void remove(Agent newOne)
Remove this actor from the agents list

Parameters:
newOne - agent to remove to the list

setUp

public void setUp()
setUp the simulation. Subclasses should call this (via super) and create agents.


openFile

public void openFile(String filename)
Open the input file and set the BufferedWriter to speak to it.


openFrames

public void openFrames(String dir)
Open a frame sequence at the given directory

Parameters:
dir - String where the directory is

run

public void run(int timeRange)
Ask all agents to run for the number of input steps


run

public void run()
Run for a default of 50 steps


endStep

public void endStep(int t)
End of step processing

Parameters:
t - timestep count

lineForFile

public String lineForFile()
lineForFile -- string to write to file on each timeStep. Will probably be overridden in subclsses.


closeFile

public void closeFile()
close the file and clear the output stream