Package org.baseagent

Class Agent

All Implemented Interfaces:
MessageListener, HasStep, SimulationListener
Direct Known Subclasses:
DrawableAgent

public class Agent extends SimulationComponent implements MessageListener, HasStep
An important aspect about this general Agent is that the only thing it maintains is internal state and knowledge. It does not specifically include those things that connect it to the world, whether that world is a Universe inside within BaseAgent
Author:
David Koelle
  • Field Details

    • SIMPLE_ID_COUNTER

      public static int SIMPLE_ID_COUNTER
  • Constructor Details

    • Agent

      public Agent()
    • Agent

      public Agent(Behavior... behaviors)
    • Agent

      public Agent(List<Behavior> behaviors)
  • Method Details

    • getSimpleID

      public int getSimpleID()
    • getType

      public SimulationComponent.Type getType()
      Specified by:
      getType in class SimulationComponent
    • step

      public void step(Simulation simulation)
      Step can be overridden, but if it's not, it will do the current behavior
      Specified by:
      step in interface HasStep
    • setKnowledge

      public void setKnowledge(Map<String,Object> knowledge)
    • getKnowledge

      public Map<String,Object> getKnowledge()
    • getInventory

      public Inventory getInventory()
    • give

      public void give(Agent recipient, Object thing)
    • receive

      public void receive(Object thing)
    • take

      public void take(Agent takee, Object thing)
    • isState

      public boolean isState(String state)
    • setState

      public void setState(String state)
    • getState

      public String getState()
    • addBehavior

      public void addBehavior(Behavior behavior)
    • addBehavior

      public void addBehavior(String name, Behavior behavior)
    • getBehavior

      public Behavior getBehavior(String name)
    • removeBehavior

      public void removeBehavior(Behavior behavior)
    • removeBehavior

      public void removeBehavior(String name)
    • getBehaviors

      public List<Behavior> getBehaviors()
    • setBehaviorPolicy

      public void setBehaviorPolicy(Behavior behaviorPolicy)
    • getBehaviorPolicy

      public Behavior getBehaviorPolicy()
    • onMessageReceived

      public void onMessageReceived(Message message)
      By default, the Agent will be sure to pass along any messages to its behaviors that are also listening for messages. When you create a subclass of Agent, you may want to call super.onMessageReceived() or passMessageToBehaviors() to continue this behavior.
      Specified by:
      onMessageReceived in interface MessageListener
    • sendMessage

      public void sendMessage(Message message)
      Convenience method to access the communicator
    • sendDirectedMessage

      public void sendDirectedMessage(MessageListener recipient, Message message)
      Convenience method to access the communicator