simbad.sim
Class Simulator

java.lang.Object
  extended bysimbad.sim.Simulator

public class Simulator
extends java.lang.Object

The Simulator class. It manages the list of agents and performs the simulation steps. For each agent a simulation step is is as follow:

  • update sensors
  • call agent performBehavior
  • update position
  • In normal operation the steps are triggered by a timer event.
    The Simulator class also provides a Background Mode with limited rendering. This mode is mainly useful for batch simulation ( ie genetic algorithms). See Also Simbatch class. Cooperates with: World, PhysicalEngine


    Constructor Summary
    Simulator(javax.swing.JComponent applicationComponent, World world, EnvironmentDescription ed)
              Constructs the simulator object
     
    Method Summary
     void dispose()
              Dispose all ressources. only called once.
     java.util.ArrayList getAgentList()
               
     float getVirtualTimeFactor()
               
     void initBehaviors()
              initialize the behavior of all agents.
     void lock()
              Obtain simulator critical resources.
     void performSimulationStep()
              Perform a single step of simulation
     void resetSimulation()
              Reset the simulation.
     void restartSimulation()
              Simulator control.
     void setApplicationComponent(javax.swing.JComponent component)
               
     void setVirtualTimeFactor(float fact)
              Set the time factor.
     void simulateOneStep()
              The main simulator method.
     void startBackgroundMode()
              Starts special background mode
     void startSimulation()
              Starts the simulator loop.
     void stopBackgroundMode()
              Stops special background mode
     void stopSimulation()
              Stop (or pause) the simulator loop.
     void unlock()
              Release simulator critical resources.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    Simulator

    public Simulator(javax.swing.JComponent applicationComponent,
                     World world,
                     EnvironmentDescription ed)
    Constructs the simulator object

    Parameters:
    applicationComponent - - A reference to the main Application container.
    world - - The 3d world object.
    ed - - the Environment description.
    Method Detail

    dispose

    public void dispose()
    Dispose all ressources. only called once.


    simulateOneStep

    public void simulateOneStep()
    The main simulator method. It is called cyclicaly or step by step. (see startSimulation).


    initBehaviors

    public void initBehaviors()
    initialize the behavior of all agents.


    startSimulation

    public void startSimulation()
    Starts the simulator loop.


    stopSimulation

    public void stopSimulation()
    Stop (or pause) the simulator loop.


    restartSimulation

    public void restartSimulation()
    Simulator control.


    resetSimulation

    public void resetSimulation()
    Reset the simulation. Resets any living agents.


    performSimulationStep

    public void performSimulationStep()
    Perform a single step of simulation


    getAgentList

    public java.util.ArrayList getAgentList()

    setVirtualTimeFactor

    public void setVirtualTimeFactor(float fact)
    Set the time factor. Used to increase or decrease the simulation rate.


    getVirtualTimeFactor

    public float getVirtualTimeFactor()

    setApplicationComponent

    public void setApplicationComponent(javax.swing.JComponent component)

    lock

    public void lock()
    Obtain simulator critical resources.


    unlock

    public void unlock()
    Release simulator critical resources.


    startBackgroundMode

    public void startBackgroundMode()
    Starts special background mode


    stopBackgroundMode

    public void stopBackgroundMode()
    Stops special background mode