Class Agent

Direct Known Subclasses:
BadAgent, BomberAgent, Jcr13Agent, RandomAgent, SecretAgent

public abstract class Agent
extends Object

Abstract interface class that must be implemented by an agent. Forces agents to implement a function that maps environment state to an action.

Your agent class MUST subclass the Agent. See Jcr13Agent for an example of how to do this.

The icon that is drawn to represent an agent is created in drawIcon. If you want to create a custom icon for your agent, override the drawIcon method. Since making a custom icon isn't necessary, we don't provide an example agent that does this.

Feel free to implement other internal methods in your Agent subclass that aren't defined in this interface. You're also free to define any needed inner classes, as well as any internal data structures. One restriction is that all of your code must be in a single java file called "NetIDAgent.java", where NetID is the net-id of one of the human members of your team. Thus, if you want to use more than one class (for example, to implement data structures), you must make inner classes. This is due to the Java restriction that each non-inner class must be defined in its own .java file.

All agents must also implement a parameterless constructor! (An easy way to meet this requirement is to write no constructor at all.)

Jason Rohrer

Field Summary
protected  Color mFillColor
protected  Color mLineColor
Constructor Summary
Method Summary
 void drawIcon(Graphics inGraphics, int inWide, int inHigh)
          Draws the icon representation for this agent.
abstract  int getMove(AgentEnvironment inEnvironment)
          Gets the agent's next move.
 void setColor(Color inLineColor, Color inFillColor)
          Sets the team color of this agent.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected Color mFillColor


protected Color mLineColor
Constructor Detail


public Agent()
Method Detail


public abstract int getMove(AgentEnvironment inEnvironment)
Gets the agent's next move. Implement this method in a class that extends Agent.
inEnvironment - the current agent-centric environment state.
an action constant. Valid values are defined in AgentAction.


public void drawIcon(Graphics inGraphics,
                     int inWide,
                     int inHigh)
Draws the icon representation for this agent. Override this method in your class that extends Agent if you want to draw a custom agent icon.
inGraphics - graphics context to draw agent icon in. Icon should be drawn in graphics in region defined by (0,0) and (inWide-1, inHigh-1).
inTeamColor - color associated with this team (can be ignored if color-independent icon alone is distinguishing enough).
inWide - width of agent icon to be drawn.
inHigh - height of agent icon to be drawn.


public final void setColor(Color inLineColor,
                           Color inFillColor)
Sets the team color of this agent.
inLineColor - line color for drawing agent.
inFillColor - fill color for drawing agent.