edu.sc.ants
Class Follower
java.lang.Object
|
+--edu.sc.ants.Thing
|
+--edu.sc.ants.Agent
|
+--edu.sc.ants.Follower
- public class Follower
- extends Agent
Follows Target agents around using a negotiation protocols to make
sure that no more than n Followers are following any given Target agent.
Inner Class Summary |
(package private) class |
Follower.BlackList
The list of all the agents a Follower agent cannot follow. |
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 |
Follower(int id,
Environment e,
java.lang.String n,
double x,
double y,
double h,
java.lang.String t)
A constructor. |
Method Summary |
void |
draw(java.awt.Graphics g,
double x,
double y,
double heading)
Draw myself |
Action |
generateAction()
Find the enemy that is closest to me and head towards him,
moving closer if I am in the correct heading. |
(package private) Action |
getFollowAction(Observation best,
double bestDist)
Get an action that will make this agent follow an agent at location best. |
(package private) Action |
getRunAwayAction(Observation best,
double bestDist)
Get an action that will make this agent run away from the agent at location best. |
void |
processInput()
Incorporate all the observations that the agent hears about
and broadcasts all that
the agent knows (so others can hear this and do likewise). |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
blackList
Follower.BlackList blackList
- The blacklist
currentTarget
int currentTarget
- ID of the agent I am currently following. -1 if none
lastFollowMessage
long lastFollowMessage
- Time when I last told currentTarget I was following it
timeBetweenFollowMessages
long timeBetweenFollowMessages
- Time between successive notifications to the target that I am
following it, in miliseconds.
timeExpireBlackList
long timeExpireBlackList
- Time an agent remains in my blacklist, in ms
Follower
public Follower(int id,
Environment e,
java.lang.String n,
double x,
double y,
double h,
java.lang.String t)
- A constructor.
- 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
draw
public void draw(java.awt.Graphics g,
double x,
double y,
double heading)
- Draw myself
- Overrides:
- draw in class Thing
processInput
public void processInput()
- Incorporate 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 Agent
generateAction
public Action generateAction()
- Find the enemy that is closest to me and head towards him,
moving closer if I am in the correct heading. If there are no
enemies visible just move around randomly.
- Overrides:
- generateAction in class Agent
getFollowAction
Action getFollowAction(Observation best,
double bestDist)
- Get an action that will make this agent follow an agent at location best.
- Parameters:
best
- the location of the target agentbestDist
- the distance of the target agent to me- Returns:
- action to either move closer or try to face in the right direction
getRunAwayAction
Action getRunAwayAction(Observation best,
double bestDist)
- Get an action that will make this agent run away from the agent at location best.
- Parameters:
best
- the location of the target agentbestDist
- the distance of the target agent to me- Returns:
- action to either move away or try to face in the right direction