biosim.core.sim
Class Environment
java.lang.Object
biosim.core.sim.Environment
- All Implemented Interfaces:
- sim.engine.MakesSimState
public class Environment
- extends java.lang.Object
- implements sim.engine.MakesSimState
Environment is a helper class for setting up the initial state of
a Simulation before it is run.
An example of typical usage is given in biosim.app.tutorial.Tutorial.
Constructor Summary |
Environment(double width,
double height,
double resolution)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
obstacles
public java.util.ArrayList<Obstacle> obstacles
obstacleLocations
public java.util.ArrayList<sim.util.Double2D> obstacleLocations
initialBodies
public java.util.ArrayList<Body> initialBodies
poi
public java.util.ArrayList<java.lang.String> poi
poiLocations
public java.util.ArrayList<sim.util.Double2D> poiLocations
width
public double width
height
public double height
resolution
public double resolution
Environment
public Environment(double width,
double height,
double resolution)
setFieldDiscretizationSize
public void setFieldDiscretizationSize(double d)
setToroidal
public void setToroidal(boolean t)
addStaticPOI
public void addStaticPOI(java.lang.String name,
double x,
double y)
addObstacle
public void addObstacle(Obstacle o,
double x,
double y)
addBody
public void addBody(Body b)
newInstance
public sim.engine.SimState newInstance(long seed,
java.lang.String[] args)
- Specified by:
newInstance
in interface sim.engine.MakesSimState
simulationClass
public java.lang.Class simulationClass()
- Specified by:
simulationClass
in interface sim.engine.MakesSimState
newSimulation
public Simulation newSimulation()
newSimulation
public Simulation newSimulation(long seed)
- Convenience method for generating Simulation objects.
Used primarily to generate simulation objects to the
GUISimulation class. Use runSimulation(...) for non-gui
runs.
addObjectsToSim
protected void addObjectsToSim(Simulation sim)
initSimField
protected void initSimField(Simulation sim)
- Method which initializes the Simulation object's internal field2D. A Simulation
object does not initalize it's internal field2D object in its constructor
because it may not have access to an Environment object until after it has been
created. By default Obstacle and POI objects are initialized at fixed locations
and Body objects are initialized to random locations within the field2D that
do not collide with any obstacle. Users are encouraged to override this method
for more control over how object locations are initialized.
configSim
protected void configSim(Simulation sim)
- Method which sets up a simulation according to the configuration
modeled by this class. This method is called by newSimulation()
and runSimulation() on newly created Simulation objects, and by
Simulation.start(). It in turn calls addObjectsToSim(...) to
add Body, Obstacle, and POI objects to the Simulation object, and
then initSimField(sim) to add these objects to its field2D.
Users who want control over where Body objects are initally
placed should override the initSimField method in a subclass.
runSimulation
public void runSimulation(java.lang.String[] args)