se.sics.tasim.aw
Class Agent

java.lang.Object
  extended by se.sics.tasim.aw.Agent

public abstract class Agent
extends java.lang.Object

The abstract class Agent should be inherited by all implementations of agents that wants to be able to participate in TAC Games or other Trading Agent Simulations on the TAC SCM Simulator. Agents can be run both within the Simulator as built-in agents or they can run outside the Simulator (in the AgentWare) and connect to it via Internet. Features of Agent:

Note: the agent must wait for its initialization before calling any of the inherited methods! The agent is initialized by a call to simulationSetup.


Field Summary
static java.lang.String ADMIN
          The address to the server administrator
static java.lang.String COORDINATOR
          The address to the simulation coordinator
 
Constructor Summary
protected Agent()
           
 
Method Summary
protected  void addTimeListener(TimeListener listener)
          Adds the specified time listener to receive notifications about time units.
 java.lang.String getAddress()
          Returns the address of this agent
 java.lang.String getName()
          Returns the name of this agent
protected  int getNextID()
          Returns a unique ID for use in various messages
protected  long getServerTime()
          Returns the server time.
protected abstract  void messageReceived(Message message)
          messageReceived is called when a message to the agent is received.
protected  void removeTimeListener(TimeListener listener)
          Removes the specified time listener so that it no longer receives notifications about time units.
protected  void sendMessage(Message message)
          Send a message to another agent in a game/simulation
protected  void sendMessage(java.lang.String receiver, Transportable content)
          Create and send a message to another agent in a game/simulation
protected  void sendMessages(java.util.Hashtable messageTable)
          Extract all receivers and message contents from the hash table and sends them.
protected  void sendToRole(int role, Transportable content)
           
protected abstract  void simulationFinished()
          Called when a game/simulation is finished and the agent should free its resources.
protected abstract  void simulationSetup()
          Called when a game/simulation is starting and the agent should initialize
protected  void simulationStopped()
          Called when a game/simulation is in the process of being stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COORDINATOR

public static final java.lang.String COORDINATOR
The address to the simulation coordinator

See Also:
Constant Field Values

ADMIN

public static final java.lang.String ADMIN
The address to the server administrator

See Also:
Constant Field Values
Constructor Detail

Agent

protected Agent()
Method Detail

getName

public java.lang.String getName()
Returns the name of this agent


getAddress

public java.lang.String getAddress()
Returns the address of this agent


getServerTime

protected long getServerTime()
Returns the server time. Note that this is an approximation when agent is not executing as "built-in".


getNextID

protected int getNextID()
Returns a unique ID for use in various messages


addTimeListener

protected void addTimeListener(TimeListener listener)
Adds the specified time listener to receive notifications about time units.

Parameters:
listener - the time listener

removeTimeListener

protected void removeTimeListener(TimeListener listener)
Removes the specified time listener so that it no longer receives notifications about time units.

Parameters:
listener - the time listener

sendMessage

protected void sendMessage(Message message)
Send a message to another agent in a game/simulation

Parameters:
message - to send

sendMessage

protected void sendMessage(java.lang.String receiver,
                           Transportable content)
Create and send a message to another agent in a game/simulation

Parameters:
receiver - of the message
content - of the message

sendMessages

protected void sendMessages(java.util.Hashtable messageTable)
Extract all receivers and message contents from the hash table and sends them.

Parameters:
messageTable - a Hashtable mapping agent addresses (receivers) with Transportable objects (message contents)

sendToRole

protected void sendToRole(int role,
                          Transportable content)

messageReceived

protected abstract void messageReceived(Message message)
messageReceived is called when a message to the agent is received.

Parameters:
message - the received message

simulationSetup

protected abstract void simulationSetup()
Called when a game/simulation is starting and the agent should initialize


simulationStopped

protected void simulationStopped()
Called when a game/simulation is in the process of being stopped. The agent might still receive messages after this call has been made but can not send messages itself.


simulationFinished

protected abstract void simulationFinished()
Called when a game/simulation is finished and the agent should free its resources.



Copyright © 2007-2009 Association for Trading Agent Research. All Rights Reserved.