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.
 
Field Summary
(package private)  Follower.BlackList blackList
          The blacklist
(package private)  int currentTarget
          ID of the agent I am currently following.
(package private)  long lastFollowMessage
          Time when I last told currentTarget I was following it
(package private)  long timeBetweenFollowMessages
          Time between successive notifications to the target that I am following it, in miliseconds.
(package private)  long timeExpireBlackList
          Time an agent remains in my blacklist, in ms
 
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 edu.sc.ants.Agent
drawInfo
 
Methods inherited from class edu.sc.ants.Thing
draw, expireObservations, incorporateObservations, incorporateOthersObservations, resume, run, start, stop, suspend
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

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 reside
n - name
x - x location on the panel
y - y location on the panel
h - heading
t - type
Method Detail

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 agent
bestDist - 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 agent
bestDist - the distance of the target agent to me
Returns:
action to either move away or try to face in the right direction