edu.sc.ants
Class Agent
java.lang.Object
|
+--edu.sc.ants.Thing
|
+--edu.sc.ants.Agent
- Direct Known Subclasses:
- EnemyAgent, Follower, GoodAgent, Target
- public class Agent
- extends Thing
An Agent is a Thing that can take action. Probably all test agents
should inherit from this class. Once you do that, all you need to
do is to define your own processInput() and generateAction()
methods to do whatever you want.
Fields inherited from class edu.sc.ants.Thing |
env,
fixed,
heading,
lastInput,
myBroadcastRange,
myColor,
myExpireWait,
myID,
mySensingRange,
mySize,
name,
running,
suspended,
type,
xLocation,
yLocation |
Constructor Summary |
Agent(int id,
Environment e,
java.lang.String n,
double x,
double y,
double h,
java.lang.String t)
A constructor. |
Method Summary |
void |
drawInfo(java.awt.Graphics g)
Draws lines from where I think I am to where I think everyone
else is. |
Action |
generateAction()
This method needs to return the action the agent wants to take
at that particular time. |
void |
processInput()
This method needs to handle all input and send any messages
that need to be sent. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
Agent
public Agent(int id,
Environment e,
java.lang.String n,
double x,
double y,
double h,
java.lang.String t)
- A constructor. We need to define this because it will not compile
without it.
- Parameters:
id
- my unique ID.e
- the enviroment on which I residen
- namex
- x location on the panely
- y location on the panelh
- headingt
- type
processInput
public void processInput()
- This method needs to handle all input and send any messages
that need to be sent. This implementation incorporates all the
observations that the agent hears about and broadcasts all that
the agent knows (so others can hear this and do likewise).
- Overrides:
- processInput in class Thing
generateAction
public Action generateAction()
- This method needs to return the action the agent wants to take
at that particular time. @see Action. The default is to take a
random action.
- Overrides:
- generateAction in class Thing
drawInfo
public void drawInfo(java.awt.Graphics g)
- Draws lines from where I think I am to where I think everyone
else is.