Class AbstractDedaleAgent

java.lang.Object
jade.core.Agent
agent.AbstractDeltaAgent
eu.su.mas.dedale.mas.AbstractDedaleAgent
All Implemented Interfaces:
agent.A2oInterface, jade.core.TimerListener, jade.util.leap.Serializable, Serializable, Runnable
Direct Known Subclasses:
ControlledAgent, DummyCollectorAgent, DummyMovingAgent, DummyTankerAgent, DummyWumpusShift, DummyWumpusShift2, ExploreCoopAgent, ExploreSoloAgent

public class AbstractDedaleAgent extends agent.AbstractDeltaAgent
 Any agent willing to interact with a the DEDALE environment must extend this class it offers :
 
  • the API to move and act in the env, either it is distributed or not
  • the management of the communication reach
  • the deployment of the agent
Author:
Cédric Herpson.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class jade.core.Agent

    jade.core.Agent.Interrupted
  • Field Summary

    Fields inherited from class jade.core.Agent

    AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN, MSG_QUEUE_CLASS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    boolean
    Close all the safes present on the current position.
    void
    Used to get a ref of this environment from the genericSharableObject table to realEnv, as well as the agents characteristics obtained through the configurationFile This methods is silently called by the agent when discussing with the gateKeeper.
    void
    Drop the treasure on the current position, if allowed (depending of the agent's type) and elements already on the current location (one type of treasure per node)
    boolean
    emptyMyBackPack(String agentSiloName)
    Allow the agent to transfer its backpack within a Tanker agent if there is one in the vicinity
    List<dataStructures.tuple.Couple<Observation,Integer>>
     
     
    Set<dataStructures.tuple.Couple<Observation,Integer>>
     
     
    static Object[]
    loadEntityCaracteristics(String agentName, String instanceConfigurationEntitiesFullPath)
    Search and load the characteristics of one agent.
    boolean
    moveTo(Location myDestination)
    This method should be the last method called in your behaviour.
    List<dataStructures.tuple.Couple<Location,List<dataStructures.tuple.Couple<Observation,String>>>>
     
    boolean
    This methods automatically aggregates the surrounding connected agents expertise
    int
     
    void
    sendMessage(jade.lang.acl.ACLMessage msg)
    This method MUST be used instead of the final method JADE.core.Agent.send() in order for the platform to control the reach of the communications.
    protected void
    This method is automatically called when a Dedale agent is created.
    protected void
     
    boolean
    throwGrenade(Location locationId)
    Throw a grenade to a given location.

    Methods inherited from class agent.AbstractDeltaAgent

    addAbility, addSharableObject, getKnowledge, getKnowledge, getSharableObject, removeSharableObject, setKnowledge

    Methods inherited from class jade.core.Agent

    addBehaviour, afterClone, beforeClone, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, createMessageQueue, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAID, getAMS, getArguments, getBehavioursCnt, getBootProperties, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getExecutedBehavioursCnt, getGenerateBehaviourEvents, getGenerateMessageEvents, getHap, getHelper, getLocalName, getName, getO2AInterface, getO2AObject, getPostedMessagesCnt, getProperty, getQueueSize, getReceivedMessagesCnt, getSentMessagesCnt, getState, here, isAlive, isRestarting, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, receive, registerO2AInterface, removeBehaviour, removeTimer, restartLater, restoreBufferedState, restoreFields, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setGenerateMessageEvents, setO2AManager, setQueueSize, waitUntilStarted, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractDedaleAgent

      public AbstractDedaleAgent()
    • AbstractDedaleAgent

      public AbstractDedaleAgent(EntityType e, EntityCharacteristics ec, String environmentName)
      Parameters:
      e - the type of agent to create
      ec - its characteristics
      environmentName - name of the environment to deploy the agent
  • Method Details

    • getCurrentPosition

      public Location getCurrentPosition()
      Returns:
      The agent's current position, null if the agent is not in the environment
    • observe

      public List<dataStructures.tuple.Couple<Location,List<dataStructures.tuple.Couple<Observation,String>>>> observe()
      Returns:
      The available observations from the agent's current position.

      A list of observed position (PositionID), and for each one is associated its list of observations under the form (ObservationType, Value)) . Null if there is a malfunction

      Example : {

      Position1; [(Observation1,Value1);(Observation2,Value2)],

      Position2; [(Observation1,Value1);(Observation2,Value2)],

      ..}

      See Also:
    • moveTo

      public boolean moveTo(Location myDestination)
      This method should be the last method called in your behaviour.

      The agent can die if he moves too carelessly.

      Parameters:
      myDestination - the targeted nodeId
      Returns:
      true if the move is legit and triggered, false otherwise
    • pick

      public int pick()
      Returns:
      the amount of wealth that the agent was able to pick. 0 if there is no treasure at this place, or if the agent cannot grab it ( backPack full, not authorized,...)
    • openLock

      public boolean openLock(Observation o)
      This methods automatically aggregates the surrounding connected agents expertise
      Parameters:
      o - The type of treasure to open (Observation.Gold, Observation.Diamond, Observation.Any).
      Returns:
      true is the lock is open, false otherwise
    • closeLock

      public boolean closeLock()
      Close all the safes present on the current position.
      Returns:
      true if at least one chest with a lock was on the agent position (all chest on the position are now locked)
    • getBackPackFreeSpace

      public List<dataStructures.tuple.Couple<Observation,Integer>> getBackPackFreeSpace()
      Returns:
      The available carrying capacity of the agent according to its type. As an agent can carry several type of resources, its a list of Couple<Observation,Value>
    • getMyTreasureType

      public Observation getMyTreasureType()
      Returns:
      The type of treasure that the agent is able to pick
    • getMyExpertise

      public Set<dataStructures.tuple.Couple<Observation,Integer>> getMyExpertise()
      Returns:
      The expertise of the agent as a set of Couple(Observation,Integer)
    • emptyMyBackPack

      public boolean emptyMyBackPack(String agentSiloName)
      Allow the agent to transfer its backpack within a Tanker agent if there is one in the vicinity
      Parameters:
      agentSiloName - name of the Tanker agent to receive the backpack's content
      Returns:
      true if you're agent was allowed to realize the transfer, false otherwise
    • throwGrenade

      public boolean throwGrenade(Location locationId)
      Throw a grenade to a given location.
      Parameters:
      locationId - the Id of the room the entity is aiming at
      Returns:
      true if done, false otherwise (the location as to far,..) The consequences of this action, if any, will be seen in the environment
    • dropOff

      public void dropOff()
      Drop the treasure on the current position, if allowed (depending of the agent's type) and elements already on the current location (one type of treasure per node)
    • sendMessage

      public void sendMessage(jade.lang.acl.ACLMessage msg)
      This method MUST be used instead of the final method JADE.core.Agent.send() in order for the platform to control the reach of the communications. To receive the message, use the original JADE.core.Agent.receive() method.
      Parameters:
      msg - the message to send
    • deployMe

      public void deployMe()
      Used to get a ref of this environment from the genericSharableObject table to realEnv, as well as the agents characteristics obtained through the configurationFile This methods is silently called by the agent when discussing with the gateKeeper. The end-user should NOT call it.
    • loadEntityCaracteristics

      public static Object[] loadEntityCaracteristics(String agentName, String instanceConfigurationEntitiesFullPath)
      Search and load the characteristics of one agent.
      Parameters:
      agentName - localname of the agent
      instanceConfigurationEntitiesFullPath - file describing the agent characteristics
      Returns:
      The entity characteristics as an object tabular
    • setup

      protected void setup()
      This method is automatically called when a Dedale agent is created. It initialize its internal variables and add the mandatory abilities of any dedale's agent :
      • To deploy itself within the environment and let its internal treasure state be observable :DeployMe
      • To received treasures if the agent's type is "tanker"
      • To be called back home when the network migration is allowed
      • To be killed from and by Home when the network migration is allowed
      Overrides:
      setup in class jade.core.Agent
    • takeDown

      protected void takeDown()
      Overrides:
      takeDown in class jade.core.Agent
    • beforeMove

      protected void beforeMove()
      Overrides:
      beforeMove in class jade.core.Agent
    • afterMove

      protected void afterMove()
      Overrides:
      afterMove in class jade.core.Agent