appletbots.tag
Class TagAgent
java.lang.Object
appletbots.WorldObject
appletbots.Agent
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
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TagAgent
public TagAgent(int size,
int sight,
double maxSpeed,
double maxAcceleration)
- Constructs a new TagAgent with the given parameters
- Parameters:
size
- The agent's radiussight
- The distance the agent can seemaxSpeed
- The maximum speed the agent can travelmaxAcceleration
- The maximum acceleration for this agent
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