edu.turtlekit2.kernel.agents
Class Observer

java.lang.Object
  extended by madkit.kernel.AbstractAgent
      extended by madkit.kernel.Watcher
          extended by edu.turtlekit2.kernel.agents.Observer
All Implemented Interfaces:
Serializable, madkit.kernel.ReferenceableAgent
Direct Known Subclasses:
CircleFiller, FoodInitializer, FoodInitializer, GradientBuilder, GridColorFiller, GridColorPlayer, GridInitializer, GridPlayer, NoiseGenerator, PatchInitializer, SoccerObserver, Viewer

public abstract class Observer
extends madkit.kernel.Watcher
implements madkit.kernel.ReferenceableAgent

Observer is an abstract class that have to be extended in order to initialize patches or make some observations. To observe turtle, create TurtleProbe on a special role and then add it using addProbe(); walkers = new TurtleProbe(getSimulationGroup(),"walker"); addProbe(walkers); You can specially create Turtle[] variables using TurtleProbe's getTurtles() method. This method permits to obtain an array of turtle regarding the role they play. MoreOver this agent has access to the patchGrid variable in order to observe or initialize the patches.

Version:
3.0 20/02/2002
Author:
Fabien MICHEL, Gregory BEURIER
See Also:
TurtleProbe, Serialized Form

Field Summary
 XMLAttributes attrib
           
 int envHeight
           
 int envWidth
           
 ArrayList<PatchVariable> flavors
           
 Map<String,GridVariable> gridValues
           
 Patch[][] patchGrid
           
protected  edu.turtlekit2.kernel.agents.EnvProbe probe1
           
protected  edu.turtlekit2.kernel.agents.EnvProbe probe2
           
 String simulationGroup
           
 
Constructor Summary
Observer()
           
 
Method Summary
 void activate()
          MadKit kernel usage
 boolean flavorsContains(String name)
           
 double[][] getAllValues(String variableName)
           
 XMLAttributes getAttrib()
           
 boolean getBooleanParam(String key)
           
 boolean getBooleanParam(String key, boolean defaultValue)
           
 Color getColorParam(String key)
           
 Color getColorParam(String key, Color defaultValue)
           
 double getDoubleParam(String key)
           
 double getDoubleParam(String key, double defaultValue)
           
 PatchVariable getFlavor(int i)
           
 String getFlavorName(int i)
           
 ArrayList<PatchVariable> getFlavors()
          PatchVariables Methods for obs
 float getFloatParam(String key)
           
 float getFloatParam(String key, float defaultValue)
           
 int getIntParam(String key)
           
 int getIntParam(String key, int defaultValue)
           
 String getParam(String key)
           
 String getParam(String key, String defaultValue)
           
 String getSimulationGroup()
           
 String getStringParam(String key)
           
 String getStringParam(String key, String defaultValue)
           
 void setAttrib(XMLAttributes attrib)
           
 void setFlavors(ArrayList<PatchVariable> flavors)
           
 void setup()
          override this method to make other initializations,not in constructor
 void watch()
          override this method to observe the state of the world using turtle tables or/and the patchGrid variable
 
Methods inherited from class madkit.kernel.Watcher
addProbe, addProbe, end, getProbes, removeAllProbes, removeProbe, update
 
Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, disposeMyGUI, foundGroup, getAddress, getAgentInformation, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, hashCode, initGUI, isBelongingToGroup, isBelongingToGroup, isCommunity, isGroup, isGroup, isMemberOf, isMemberOf, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, println, receiveMessage, 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

simulationGroup

public String simulationGroup

patchGrid

public Patch[][] patchGrid

gridValues

public Map<String,GridVariable> gridValues

envWidth

public int envWidth

envHeight

public int envHeight

attrib

public XMLAttributes attrib

flavors

public ArrayList<PatchVariable> flavors

probe1

protected edu.turtlekit2.kernel.agents.EnvProbe probe1

probe2

protected edu.turtlekit2.kernel.agents.EnvProbe probe2
Constructor Detail

Observer

public Observer()
Method Detail

activate

public void activate()
MadKit kernel usage

Overrides:
activate in class madkit.kernel.AbstractAgent

getAllValues

public double[][] getAllValues(String variableName)

getSimulationGroup

public final String getSimulationGroup()

watch

public void watch()
override this method to observe the state of the world using turtle tables or/and the patchGrid variable


setup

public void setup()
override this method to make other initializations,not in constructor


getAttrib

public XMLAttributes getAttrib()

setAttrib

public void setAttrib(XMLAttributes attrib)

getFlavors

public ArrayList<PatchVariable> getFlavors()
PatchVariables Methods for obs


getFlavor

public PatchVariable getFlavor(int i)

getFlavorName

public String getFlavorName(int i)

flavorsContains

public boolean flavorsContains(String name)

setFlavors

public void setFlavors(ArrayList<PatchVariable> flavors)
Parameters:
flavors - The flavors to set.

getIntParam

public int getIntParam(String key)

getIntParam

public int getIntParam(String key,
                       int defaultValue)

getDoubleParam

public double getDoubleParam(String key)

getDoubleParam

public double getDoubleParam(String key,
                             double defaultValue)

getFloatParam

public float getFloatParam(String key)

getFloatParam

public float getFloatParam(String key,
                           float defaultValue)

getStringParam

public String getStringParam(String key)

getStringParam

public String getStringParam(String key,
                             String defaultValue)

getParam

public String getParam(String key)

getParam

public String getParam(String key,
                       String defaultValue)

getBooleanParam

public boolean getBooleanParam(String key)

getBooleanParam

public boolean getBooleanParam(String key,
                               boolean defaultValue)

getColorParam

public Color getColorParam(String key)

getColorParam

public Color getColorParam(String key,
                           Color defaultValue)