net.sourceforge.jabm.agent
Class AbstractAgent

java.lang.Object
  extended by net.sourceforge.jabm.agent.AbstractAgent
All Implemented Interfaces:
java.io.Serializable, Agent, EventListener

public abstract class AbstractAgent
extends java.lang.Object
implements java.io.Serializable, Agent

An abstract superclass for JABM agents which provides default event-handling functionality implementing several methods in the Agent interface. The only requirement for an object to model a JABM agent is that it implement the Agent interface; agents do not have to subclass AbstractAgent.

See Also:
Serialized Form
 

Field Summary
protected  boolean interacted
           
protected  EventScheduler scheduler
          The event scheduler used to fire events originating from this agent.
protected  Strategy strategy
           
 
Constructor Summary
AbstractAgent()
           
AbstractAgent(EventScheduler scheduler)
           
 
Method Summary
 void eventOccurred(SimEvent event)
           
 void fireEvent(SimEvent event)
           
 double getPayoffDelta()
           
 EventScheduler getScheduler()
           
 Strategy getStrategy()
           
 boolean isInteracted()
          Find out whether the agent has interacted with the environment or other agents.
 void onAgentArrival(AgentArrivalEvent event)
          This method is called whenever an agent arrives at the simulation.
 void onRoundStarting(RoundStartingEvent event)
           
 void onSimulationFinished(SimulationFinishedEvent event)
           
 void setScheduler(EventScheduler scheduler)
          Set the event scheduler for this agent.
 void setStrategy(Strategy strategy)
          Configure the strategy for this agent.
 void subscribeToEvents()
          Subscribe to the specific events that we are interested in.
 void unsubscribeFromEvents()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jabm.agent.Agent
getPayoff, initialise
 

Field Detail

interacted

protected boolean interacted

scheduler

protected EventScheduler scheduler
The event scheduler used to fire events originating from this agent.


strategy

protected Strategy strategy
Constructor Detail

AbstractAgent

public AbstractAgent(EventScheduler scheduler)

AbstractAgent

public AbstractAgent()
Method Detail

subscribeToEvents

public void subscribeToEvents()
Subscribe to the specific events that we are interested in.


unsubscribeFromEvents

public void unsubscribeFromEvents()

eventOccurred

public void eventOccurred(SimEvent event)
Specified by:
eventOccurred in interface EventListener

onSimulationFinished

public void onSimulationFinished(SimulationFinishedEvent event)

onRoundStarting

public void onRoundStarting(RoundStartingEvent event)

fireEvent

public void fireEvent(SimEvent event)

getScheduler

public EventScheduler getScheduler()

setScheduler

public void setScheduler(EventScheduler scheduler)
Description copied from interface: Agent
Set the event scheduler for this agent.

Specified by:
setScheduler in interface Agent

getPayoffDelta

public double getPayoffDelta()
Specified by:
getPayoffDelta in interface Agent
Returns:
the change in payoff during the most recent period.

onAgentArrival

public void onAgentArrival(AgentArrivalEvent event)
This method is called whenever an agent arrives at the simulation. The default behaviour is to execute the agent's strategy.


isInteracted

public boolean isInteracted()
Description copied from interface: Agent
Find out whether the agent has interacted with the environment or other agents.

Specified by:
isInteracted in interface Agent

getStrategy

public Strategy getStrategy()
Specified by:
getStrategy in interface Agent
Returns:
the current Strategy used by this agent.

setStrategy

public void setStrategy(Strategy strategy)
Configure the strategy for this agent.

Specified by:
setStrategy in interface Agent