org.vizzini.game
Class AbstractAgent

java.lang.Object
  extended by org.vizzini.game.AbstractAgent
All Implemented Interfaces:
Serializable, IAgent
Direct Known Subclasses:
AbstractComputerAgent, AbstractHumanAgent, DefaultAgent

public abstract class AbstractAgent
extends Object
implements IAgent

Provides base functionality for agents in the game framework. An agent instance encapsulates the logic an agent uses to create actions. Examples of this logic are simple coding, a minimax algorithm, or neural network based.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.vizzini.game.IAgent
NAME_PROPERTY, TEAM_PROPERTY
 
Constructor Summary
AbstractAgent()
           
 
Method Summary
 void addConcedeListener(IConcedeListener listener)
          Add the given listener.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 void addScoreListener(IScoreListener listener)
          Add the given listener.
 void addToScore(long value)
          Add the given value to the score.
 void concede()
          Concede the game.
 void configure(Properties properties, int index)
          Configure this agent.
 boolean equals(Object object)
          Return true if the given object is equal to this.
protected  ConcedeManager getConcedeManager()
          Return the concede manager.
protected  int getIndex()
           
 String getName()
          Return this agent's name.
protected  Properties getProperties()
           
protected  PropertyChangeManager getPropertyChangeManager()
          Return the property change manager.
 long getScore()
          Return the current score.
protected  ScoreManager getScoreManager()
          Return the score manager.
 ITeam getTeam()
          Return this agent's team.
 ITokenCollection getTokenCollection()
          Return the token collection.
protected  Class getTokenCollectionClass()
           
 int hashCode()
          Returns a hash code value for the object.
 void incrementScore()
          Increment the score.
 void removeConcedeListener(IConcedeListener listener)
          Remove the given listener.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void removeScoreListener(IScoreListener listener)
          Remove the given listener.
 void reset()
          Reset to the initial state.
 void setName(String name)
          Set the name to the given name.
 void setScore(long score)
          Set the score to the given value.
 void setTeam(ITeam team)
          Set the associated team.
protected  void setTokenCollectionClass(Class tokenCollectionClass)
           
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.IAgent
getAction
 

Constructor Detail

AbstractAgent

public AbstractAgent()
Method Detail

addConcedeListener

public void addConcedeListener(IConcedeListener listener)
Add the given listener.

Specified by:
addConcedeListener in interface IAgent
Since:
v0.1

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.

Specified by:
addPropertyChangeListener in interface IAgent
Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added.
Since:
v0.2

addScoreListener

public void addScoreListener(IScoreListener listener)
Add the given listener.

Specified by:
addScoreListener in interface IAgent
Since:
v0.1

addToScore

public void addToScore(long value)
Add the given value to the score.

Specified by:
addToScore in interface IAgent
Parameters:
value - The value to add.
Since:
v0.1

concede

public void concede()
Concede the game.

Specified by:
concede in interface IAgent
Since:
v0.1

configure

public void configure(Properties properties,
                      int index)
               throws InstantiationException,
                      IllegalAccessException
Configure this agent.

Specified by:
configure in interface IAgent
Throws:
InstantiationException
IllegalAccessException
Since:
v0.1

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.1

getName

public String getName()
Return this agent's name.

Specified by:
getName in interface IAgent
Since:
v0.1

getScore

public long getScore()
Return the current score.

Specified by:
getScore in interface IAgent
Since:
v0.1

getTeam

public ITeam getTeam()
Return this agent's team.

Specified by:
getTeam in interface IAgent
Since:
v0.1

getTokenCollection

public ITokenCollection getTokenCollection()
Return the token collection.

Specified by:
getTokenCollection in interface IAgent
Since:
v0.1

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.1

incrementScore

public void incrementScore()
Increment the score.

Specified by:
incrementScore in interface IAgent
Since:
v0.1

removeConcedeListener

public void removeConcedeListener(IConcedeListener listener)
Remove the given listener.

Specified by:
removeConcedeListener in interface IAgent
Since:
v0.1

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.

Specified by:
removePropertyChangeListener in interface IAgent
Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.
Since:
v0.2

removeScoreListener

public void removeScoreListener(IScoreListener listener)
Remove the given listener.

Specified by:
removeScoreListener in interface IAgent
Since:
v0.1

reset

public void reset()
Reset to the initial state.

Specified by:
reset in interface IAgent
Since:
v0.1

setName

public void setName(String name)
Set the name to the given name.

Specified by:
setName in interface IAgent
Parameters:
name - The new name.
Since:
v0.1

setScore

public void setScore(long score)
Set the score to the given value.

Specified by:
setScore in interface IAgent
Parameters:
score - The new score.
Since:
v0.1

setTeam

public void setTeam(ITeam team)
Set the associated team.

Specified by:
setTeam in interface IAgent
Parameters:
team - The associated team.
Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1

getConcedeManager

protected ConcedeManager getConcedeManager()
Return the concede manager.

Since:
v0.1

getIndex

protected int getIndex()
Returns:
the properties index for this agent.
Since:
v0.3

getProperties

protected Properties getProperties()
Returns:
the properties.
Since:
v0.3

getPropertyChangeManager

protected PropertyChangeManager getPropertyChangeManager()
Return the property change manager.

Since:
v0.2

getScoreManager

protected ScoreManager getScoreManager()
Return the score manager.

Since:
v0.1

getTokenCollectionClass

protected Class getTokenCollectionClass()
Returns:
Return tokenCollectionClass.
Since:
v0.2

setTokenCollectionClass

protected void setTokenCollectionClass(Class tokenCollectionClass)
Parameters:
tokenCollectionClass - The tokenCollectionClass to set.
Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02