Package org.baseagent
Class Agent
java.lang.Object
org.baseagent.sim.SimulationComponent
org.baseagent.Agent
- All Implemented Interfaces:
MessageListener
,HasStep
,SimulationListener
- Direct Known Subclasses:
DrawableAgent
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.baseagent.sim.SimulationComponent
SimulationComponent.Type
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBehavior
(String name, Behavior behavior) void
addBehavior
(Behavior behavior) getBehavior
(String name) int
getState()
getType()
void
boolean
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.void
void
removeBehavior
(String name) void
removeBehavior
(Behavior behavior) void
sendDirectedMessage
(MessageListener recipient, Message message) Convenience method to access the communicatorvoid
sendMessage
(Message message) Convenience method to access the communicatorvoid
setBehaviorPolicy
(Behavior behaviorPolicy) void
setKnowledge
(Map<String, Object> knowledge) void
void
step
(Simulation simulation) Step can be overridden, but if it's not, it will do the current behaviorvoid
Methods inherited from class org.baseagent.sim.SimulationComponent
getSimulation, getUUID, setSimulation
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.baseagent.sim.SimulationListener
onAfterStepEnded, onAfterStepStarted, onBeforeStepEnded, onBeforeStepStarted, onSimulationComponentAdded, onSimulationComponentRemoved, onSimulationEnded, onSimulationPaused, onSimulationResumed, onSimulationStarted, onSimulationStopped, onStepEnded, onStepStarted
-
Field Details
-
SIMPLE_ID_COUNTER
public static int SIMPLE_ID_COUNTER
-
-
Constructor Details
-
Agent
public Agent() -
Agent
-
Agent
-
-
Method Details
-
getSimpleID
public int getSimpleID() -
getType
- Specified by:
getType
in classSimulationComponent
-
step
Step can be overridden, but if it's not, it will do the current behavior -
setKnowledge
-
getKnowledge
-
getInventory
-
give
-
receive
-
take
-
isState
-
setState
-
getState
-
addBehavior
-
addBehavior
-
getBehavior
-
removeBehavior
-
removeBehavior
-
getBehaviors
-
setBehaviorPolicy
-
getBehaviorPolicy
-
onMessageReceived
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 interfaceMessageListener
-
sendMessage
Convenience method to access the communicator -
sendDirectedMessage
Convenience method to access the communicator
-