madkit.strobekit
Class StrobeAbstractAgent

java.lang.Object
  extended bymadkit.kernel.AbstractAgent
      extended bymadkit.kernel.Agent
          extended bymadkit.strobekit.StrobeAbstractAgent
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public abstract class StrobeAbstractAgent
extends madkit.kernel.Agent

The main class of the STROBEKIT agent API. Strobe agents are considered to inherit from this abstract class.

This class contains methods for:

Remarks concerning Strobe agents:

Version:
0.1 01/30/2006
Author:
Clement Jonquet - Mail to jonquet@lirmm.fr
See Also:
Serialized Form

Constructor Summary
StrobeAbstractAgent()
          Default no-args constructor, which just set-up internal structures.
StrobeAbstractAgent(java.lang.String n, java.lang.String g, java.lang.String r)
          Do the same that StrobeAbstractAgent() but set-up also agent name, group, and role.
 
Method Summary
 madkit.kernel.AgentAddress[] acquaintanceAddresses()
          Return an array of agent addresses corresponding to all the agents a Strobe agent has a cognitive environment dedicated to.
 madkit.kernel.AgentAddress[] acquaintanceAndIAddresses()
          Return an array of agent addresses corresponding to itself (first position) and all the agents it has a cognitive environment dedicated to.
 java.lang.String[] acquaintanceAndINames()
          Return an array of agent namess corresponding to itself (first position) and all the agents it has a cognitive environment dedicated to.
 java.lang.String[] acquaintanceNames()
          Return an array of agent names corresponding to all the agents a Strobe agent has a cognitive environment dedicated to.
 void activate()
          Method initially called when the micro-kernel registers the agent; Strobe agents have to use the method StrobeActivate.
abstract  void addAcquaintance(madkit.kernel.AgentAddress a)
          This method has to be redefined by Strobe agents; it corresponds to the adding acquaintance policy i.e., how a Strobe agents create a new CognitiveEnv when they meet a new agent for the very first time.
 void addAcquaintanceByCopyingGlobalEnv(madkit.kernel.AgentAddress a)
          Create a new local cognitive environment for a by copying the Strobe agent global cognitive environment.
 void addAcquaintanceByCopyingLocalEnv(madkit.kernel.AgentAddress newa, madkit.kernel.AgentAddress olda)
          Create a new local cognitive environment for newa by copying the Strobe agent local cognitive environment dedicated to olda.
 void addAcquaintanceBySharingLocalEnv(madkit.kernel.AgentAddress newa, madkit.kernel.AgentAddress olda)
          Use the same local cognitive environment for newa by sharing the Strobe agent local cognitive environment dedicated to olda.
abstract  void analyzeAnswer(java.lang.String res)
          This method has to be redefined by Strobe agents; it corresponds to the way answer returned by Strobe message evaluation are analyzed.
 void createOrJoinGroup(java.lang.String g)
          This method creates and/or joins a group corresponding to the bydefault Strobe agent group.
 StrobeMsg dynamicScheduler()
          Wait for and return the next message to interpret according to the Strobe agent policy (by default, called waitNextMessage).
 void end()
          Method called by the agent micro-kernel at the end of the agent lifecycle; Strobe agents have to use the method StrobeEnd.
 void eval(StrobeMsg msg)
          Evaluate the Strobe message in the good cognitive environment.
 CognitiveEnv getGlobalEnv()
          Return the agent global cognitive environment.
 java.util.HashMap getLocalEnvs()
          Return the agent local environments set; an hashmap of pair (AgentAddress, CognitiveEnv).
 java.lang.String getStrobeAgentGroup()
          Return the by default agent group.
 java.lang.String getStrobeAgentRole()
          Return the by default agent role.
 void initializeCognitiveEnvWith(java.lang.String scmfilename)
          Load the file scmfilename in the by default Scheme environment used for constructing CognitiveEnv of this Strobe agent.
 boolean isAlreadyAcquaintance(madkit.kernel.AgentAddress a)
          Return true if a is already an acquaintance.
 void live()
          This method defines the main behavior for threaded agents; Strobe agents have to use the method StrobeLive.
 void print()
          Browse all the cognitive environments (locals and global) and send messages present in output streams.
 StrobeMsg read()
          Choose (with Dynamic Scheduler) next message to interpret and return it; If the message sender is not already an acquaintance then addAcquaintance is called.
 void sendMessageAndPrint(madkit.kernel.AgentAddress a, StrobeMsg m)
          Print the StrobeMsg in the Strobe agent output writer just after sending it (using sendMessage).
 void setGlobalEnv(CognitiveEnv gE)
           
 void setLocalEnvs(java.util.HashMap lEs)
           
 void setStrobeAgentGroup(java.lang.String g)
           
 void setStrobeAgentRole(java.lang.String r)
           
 void strobeActivate()
          Replace the method activate for Strobe agents .
 void strobeEnd()
          Replace the method end for Strobe agents .
 void strobeLive()
          Replace the method live for Strobe agents .
 madkit.kernel.AgentAddress[] viewedAgentAddress()
          Return an array of agent addresses corresponding to all the agents (including itself) a Strobe agent can see i.e., having the same groupe and role in the "strobe" community.
 java.lang.String[] viewedAgentName()
          Return an array of agent names corresponding to all the agents (including itself) a Strobe agent can see i.e., having the same groupe and role in the "strobe" community.
 
Methods inherited from class madkit.kernel.Agent
pause, receiveMessage, run, waitNextMessage, waitNextMessage
 
Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, disposeMyGUI, foundGroup, getAddress, getAgentInformation, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, initGUI, isCommunity, isGroup, isGroup, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, println, redisplayMyGUI, requestRole, requestRole, requestRole, restoreAgent, sendMessage, sendMessage, sendMessage, setBean, setController, setDebug, setGUIObject, setName, setOutput, setOutputWriter, windowClosing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrobeAbstractAgent

public StrobeAbstractAgent()
Default no-args constructor, which just set-up internal structures.


StrobeAbstractAgent

public StrobeAbstractAgent(java.lang.String n,
                           java.lang.String g,
                           java.lang.String r)
Do the same that StrobeAbstractAgent() but set-up also agent name, group, and role.

Method Detail

getStrobeAgentGroup

public java.lang.String getStrobeAgentGroup()
Return the by default agent group.


setStrobeAgentGroup

public void setStrobeAgentGroup(java.lang.String g)

getStrobeAgentRole

public java.lang.String getStrobeAgentRole()
Return the by default agent role.


setStrobeAgentRole

public void setStrobeAgentRole(java.lang.String r)

getGlobalEnv

public CognitiveEnv getGlobalEnv()
Return the agent global cognitive environment.


setGlobalEnv

public void setGlobalEnv(CognitiveEnv gE)

getLocalEnvs

public java.util.HashMap getLocalEnvs()
Return the agent local environments set; an hashmap of pair (AgentAddress, CognitiveEnv).


setLocalEnvs

public void setLocalEnvs(java.util.HashMap lEs)

activate

public final void activate()
Method initially called when the micro-kernel registers the agent; Strobe agents have to use the method StrobeActivate.


live

public final void live()
This method defines the main behavior for threaded agents; Strobe agents have to use the method StrobeLive.


end

public final void end()
Method called by the agent micro-kernel at the end of the agent lifecycle; Strobe agents have to use the method StrobeEnd.


strobeActivate

public void strobeActivate()
Replace the method activate for Strobe agents .


strobeLive

public void strobeLive()
Replace the method live for Strobe agents .


strobeEnd

public void strobeEnd()
Replace the method end for Strobe agents .


viewedAgentAddress

public madkit.kernel.AgentAddress[] viewedAgentAddress()
Return an array of agent addresses corresponding to all the agents (including itself) a Strobe agent can see i.e., having the same groupe and role in the "strobe" community.


viewedAgentName

public java.lang.String[] viewedAgentName()
Return an array of agent names corresponding to all the agents (including itself) a Strobe agent can see i.e., having the same groupe and role in the "strobe" community.


acquaintanceAddresses

public madkit.kernel.AgentAddress[] acquaintanceAddresses()
Return an array of agent addresses corresponding to all the agents a Strobe agent has a cognitive environment dedicated to.


acquaintanceNames

public java.lang.String[] acquaintanceNames()
Return an array of agent names corresponding to all the agents a Strobe agent has a cognitive environment dedicated to.


acquaintanceAndIAddresses

public madkit.kernel.AgentAddress[] acquaintanceAndIAddresses()
Return an array of agent addresses corresponding to itself (first position) and all the agents it has a cognitive environment dedicated to.


acquaintanceAndINames

public java.lang.String[] acquaintanceAndINames()
Return an array of agent namess corresponding to itself (first position) and all the agents it has a cognitive environment dedicated to.


isAlreadyAcquaintance

public boolean isAlreadyAcquaintance(madkit.kernel.AgentAddress a)
Return true if a is already an acquaintance.


addAcquaintance

public abstract void addAcquaintance(madkit.kernel.AgentAddress a)
This method has to be redefined by Strobe agents; it corresponds to the adding acquaintance policy i.e., how a Strobe agents create a new CognitiveEnv when they meet a new agent for the very first time.


addAcquaintanceByCopyingGlobalEnv

public void addAcquaintanceByCopyingGlobalEnv(madkit.kernel.AgentAddress a)
Create a new local cognitive environment for a by copying the Strobe agent global cognitive environment.


addAcquaintanceByCopyingLocalEnv

public void addAcquaintanceByCopyingLocalEnv(madkit.kernel.AgentAddress newa,
                                             madkit.kernel.AgentAddress olda)
Create a new local cognitive environment for newa by copying the Strobe agent local cognitive environment dedicated to olda.


addAcquaintanceBySharingLocalEnv

public void addAcquaintanceBySharingLocalEnv(madkit.kernel.AgentAddress newa,
                                             madkit.kernel.AgentAddress olda)
Use the same local cognitive environment for newa by sharing the Strobe agent local cognitive environment dedicated to olda.


initializeCognitiveEnvWith

public void initializeCognitiveEnvWith(java.lang.String scmfilename)
Load the file scmfilename in the by default Scheme environment used for constructing CognitiveEnv of this Strobe agent.


createOrJoinGroup

public void createOrJoinGroup(java.lang.String g)
This method creates and/or joins a group corresponding to the bydefault Strobe agent group.


sendMessageAndPrint

public void sendMessageAndPrint(madkit.kernel.AgentAddress a,
                                StrobeMsg m)
Print the StrobeMsg in the Strobe agent output writer just after sending it (using sendMessage).


read

public StrobeMsg read()
Choose (with Dynamic Scheduler) next message to interpret and return it; If the message sender is not already an acquaintance then addAcquaintance is called.


dynamicScheduler

public StrobeMsg dynamicScheduler()
Wait for and return the next message to interpret according to the Strobe agent policy (by default, called waitNextMessage).


eval

public void eval(StrobeMsg msg)
Evaluate the Strobe message in the good cognitive environment.


print

public void print()
Browse all the cognitive environments (locals and global) and send messages present in output streams.


analyzeAnswer

public abstract void analyzeAnswer(java.lang.String res)
This method has to be redefined by Strobe agents; it corresponds to the way answer returned by Strobe message evaluation are analyzed.