appletbots.tag
Class TagAgent

java.lang.Object
  extended by appletbots.WorldObject
      extended by appletbots.Agent
          extended by appletbots.tag.TagAgent

public class TagAgent
extends Agent

If a tag agent is "it", he will try to touch whichever non-"it" agent is closest to him. When that contact is made, the agent he touched is "it". If a tag agent is not "it", he will not accelerate unless he sees an agent that is "it", in which case the non-"it" agent will accelerate away from the agent that is "it". Additionally, when an agent is tagged "it", its maximum speed decreases by 20% and it must wait 10 time cycles before accelerating; this is to prevent two agents getting locked together repeatedly tagging one another.

Author:
Erik Rasmussen

Field Summary
 
Fields inherited from class appletbots.Agent
accelerationVectorColor, maxAcceleration, sight, velocityVectorColor, world
 
Fields inherited from class appletbots.WorldObject
color, mass, maxSpeed, size
 
Constructor Summary
TagAgent(int size, int sight, double maxSpeed, double maxAcceleration)
          Constructs a new TagAgent with the given parameters
 
Method Summary
 void collidedWith(WorldObject object)
          Informs the object that it has been in a collision
 boolean isIt()
          Returns whether or not this agent is "it"
 void observeWorld()
          Observes the world, and follows the Tag Agent Algorithm.
 void setIt(boolean it)
          Sets whether or not this agent is "it"
 
Methods inherited from class appletbots.Agent
getAcceleration, getMaxAcceleration, getRandomAcceleration, getShowAcceleration, getShowVelocity, getSight, getVectorsToDraw, setAcceleration, setShowAcceleration, setShowVelocity, setWorld
 
Methods inherited from class appletbots.WorldObject
getColor, getMass, getMaxSpeed, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagAgent

public TagAgent(int size,
                int sight,
                double maxSpeed,
                double maxAcceleration)
Constructs a new TagAgent with the given parameters

Parameters:
size - The agent's radius
sight - The distance the agent can see
maxSpeed - The maximum speed the agent can travel
maxAcceleration - The maximum acceleration for this agent
Method Detail

observeWorld

public void observeWorld()
Observes the world, and follows the Tag Agent Algorithm.

Specified by:
observeWorld in class Agent

setIt

public void setIt(boolean it)
Sets whether or not this agent is "it"

Parameters:
it - Whether or not this agent is "it"

isIt

public boolean isIt()
Returns whether or not this agent is "it"

Returns:
Whether or not this agent is "it"

collidedWith

public void collidedWith(WorldObject object)
Informs the object that it has been in a collision

Overrides:
collidedWith in class WorldObject
Parameters:
object - The object collided with