turtlekit.kernel
Class Launcher

java.lang.Object
  extended by madkit.kernel.AbstractAgent
      extended by madkit.kernel.Agent
          extended by turtlekit.kernel.Launcher
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable
Direct Known Subclasses:
Creation, DiffusionTest, Epidemic, GameOfLife, GasExperiment, Gravity, HuntLauncher, HuntLauncher, HuntLauncher, HuntLauncher, Mosquitoes, OvniLauncher, PythonLauncher, Soccer, TermiteLauncher, TermiteLauncher, Walkers

public abstract class Launcher
extends Agent

This agent sets up, launches and manages Turtle based simulations. You have to defined a subclass of this one to custom and launch a simulation. Yo have at least to override the addSimulationAgents method to create the agents you want to launch in your simulation: turtles, viewers and observers. To declare patch variables (PatchVariable objects) you have to override the initializePatchVariables method.

Version:
4.0 25/04/2002
Author:
Fabien MICHEL
See Also:
Serialized Form

Field Summary
static java.lang.String COMMUNITY
           
 
Constructor Summary
Launcher()
          The constructor is where you have to change the default values of the simulation parameters using the corresponding accessors.
 
Method Summary
 void activate()
          MadKit usage
protected  void addMyScheduler(TurtleScheduler s)
          add a specific scheduler (that overrides the scheduleWorld method for example)
 void addObserver(Observer theObserver, boolean hasGUI)
          Add a specified Observer to the simulation.
 void addObserver(Observer theObserver, boolean hasGUI, java.lang.String agentName)
          Add a specified Observer to the simulation.
protected  void addPatchVariable(PatchVariable variable)
          Be careful, use this method only in the initializeSimulation method.
abstract  void addSimulationAgents()
          Override this method is compulsory (abstract).
protected  void addTurtle(Turtle t)
          place a turtle at a random patch
protected  void addTurtle(Turtle t, int u, int v)
          place a turtle on the patch (u,v).
 void addViewer()
          Add a default world viewer with the current cell size.
 void addViewer(int cellS)
          add a default world viewer with the specified cell size: cellS
 void addViewer(Viewer v)
          add a specific world viewer with the current cell size
 void addViewer(Viewer v, int cellS)
          add a specific world viewer with the specified cell size: cellS
 void addViewer(Viewer v, int cellS, java.lang.String viewerName)
          add a specific world viewer with the specified cell size: cellS
 void addViewer(Viewer v, java.lang.String viewerName)
          add a specific world viewer with the current cell size
 void end()
          MadKit kernel usage.
 int getCellSize()
           
 int getHeight()
           
 java.lang.String getSimulationName()
           
 int getWidth()
           
 void initGUI()
          MadKit kernel usage
protected  void initializePatchVariables()
          override this method is not compulsory, but it is where you have to initialize the patch variables and their properties(evaporation, diffusion...): Once you have created a new PatchVariable object and set its properties with the methods of the class PatchVariable(setEvapCoef, setDiffuseCoef and setDefaultValue) You have to add it to the simulation using the addPatchVariable method: protected void initializePatchVariables() { PatchVariable p = new PatchVariable("flavor"); p.setDiffuseCoef(0.3153); //Optional p.setEvapCoef(0.025); //Optional p.setDefaultValue(32); //Optional addPatchVariable(a); }
 void launchPython()
           
 void live()
          MadKit kernel usage
 void setCellSize(int add)
           
 void setCyclePause(int add)
           
 void setHeight(int add)
           
 void setSimulationName(java.lang.String name)
           
 void setWidth(int add)
           
 void setWrapModeOn(boolean b)
           
 void stopOrResumeSimulation()
           
 
Methods inherited from class madkit.kernel.Agent
connectAgencyToAgency, createPlace, createPlace, enableMobility, enableMobility, exitImmediatlyOnKill, getAgencyNamed, joinPlace, joinPlace, joinPlace, pause, receiveMessage, run, waitNextMessage, waitNextMessage
 
Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, destroyGroup, disposeMyGUI, foundGroup, getAddress, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, hashCode, hideMyGUI, isBelongingToGroup, isBelongingToGroup, isCommunity, isGroup, isGroup, isMemberOf, isMemberOf, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, println, redisplayMyGUI, requestRole, requestRole, requestRole, restoreAgent, sendMessage, sendMessage, sendMessage, setBean, setController, setDebug, setGUIObject, setName, setOutput, setOutputWriter, toString, windowClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMUNITY

public static final java.lang.String COMMUNITY
See Also:
Constant Field Values
Constructor Detail

Launcher

public Launcher()
The constructor is where you have to change the default values of the simulation parameters using the corresponding accessors. Default Values are: setSimulationName("? NAME ?"); //The simulation name corresponds to the Madkit group that will be created for the simulation. setWidth(100); setHeight(100); setCellSize(4); //onscreen size for patches and trutles setWrapModeOn(false); setCyclePause(10); //cycle pause represents the pause time between two simulation steps. This default quick pause is supposed to avoid that the simulation takes all ressources.

Method Detail

setWidth

public final void setWidth(int add)

getWidth

public final int getWidth()

setCellSize

public final void setCellSize(int add)

getCellSize

public final int getCellSize()

setHeight

public final void setHeight(int add)

getHeight

public final int getHeight()

getSimulationName

public final java.lang.String getSimulationName()

setSimulationName

public final void setSimulationName(java.lang.String name)

setCyclePause

public final void setCyclePause(int add)

setWrapModeOn

public final void setWrapModeOn(boolean b)

addTurtle

protected final void addTurtle(Turtle t)
place a turtle at a random patch


addTurtle

protected final void addTurtle(Turtle t,
                               int u,
                               int v)
place a turtle on the patch (u,v). Be sure to use the addTurtle methods in the addSimulationAgents method


addObserver

public final void addObserver(Observer theObserver,
                              boolean hasGUI,
                              java.lang.String agentName)
Add a specified Observer to the simulation. Be careful, use this method only in the addSimulationAgents method.


addObserver

public final void addObserver(Observer theObserver,
                              boolean hasGUI)
Add a specified Observer to the simulation. Be careful, do not use these methods before the addSimulationAgents method has been invoked. (during life cycle it is ok)


addViewer

public final void addViewer()
Add a default world viewer with the current cell size. Be careful, do not use these methods before the addSimulationAgents method has been invoked. (during life cycle it is ok)


addViewer

public final void addViewer(int cellS)
add a default world viewer with the specified cell size: cellS


addViewer

public final void addViewer(Viewer v,
                            int cellS,
                            java.lang.String viewerName)
add a specific world viewer with the specified cell size: cellS


addViewer

public final void addViewer(Viewer v,
                            int cellS)
add a specific world viewer with the specified cell size: cellS


addViewer

public final void addViewer(Viewer v,
                            java.lang.String viewerName)
add a specific world viewer with the current cell size


addViewer

public final void addViewer(Viewer v)
add a specific world viewer with the current cell size


addMyScheduler

protected final void addMyScheduler(TurtleScheduler s)
add a specific scheduler (that overrides the scheduleWorld method for example)


addPatchVariable

protected final void addPatchVariable(PatchVariable variable)
Be careful, use this method only in the initializeSimulation method. This method add a patch variable (a PatchVariable Object) defined with the PatchVariable constructor and the set methods


initializePatchVariables

protected void initializePatchVariables()
override this method is not compulsory, but it is where you have to initialize the patch variables and their properties(evaporation, diffusion...): Once you have created a new PatchVariable object and set its properties with the methods of the class PatchVariable(setEvapCoef, setDiffuseCoef and setDefaultValue) You have to add it to the simulation using the addPatchVariable method: protected void initializePatchVariables() { PatchVariable p = new PatchVariable("flavor"); p.setDiffuseCoef(0.3153); //Optional p.setEvapCoef(0.025); //Optional p.setDefaultValue(32); //Optional addPatchVariable(a); }


addSimulationAgents

public abstract void addSimulationAgents()
Override this method is compulsory (abstract). It is in this method that the optional agents of the simulation (turtles, viewers and observers) have to be added. To add these agents you have to use the "add" methods of a Launcher: - addTurtle - addViewer - addObserver


initGUI

public final void initGUI()
MadKit kernel usage

Overrides:
initGUI in class AbstractAgent

activate

public void activate()
MadKit usage

Overrides:
activate in class AbstractAgent

live

public final void live()
MadKit kernel usage

Overrides:
live in class Agent

end

public final void end()
MadKit kernel usage. No redefinition

Overrides:
end in class AbstractAgent

launchPython

public void launchPython()
                  throws java.lang.Exception
Throws:
java.lang.Exception

stopOrResumeSimulation

public void stopOrResumeSimulation()


Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.