|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object appletbots.WorldObject appletbots.Agent appletbots.CarrierAgent appletbots.gatherers.Gatherer
public class Gatherer
A gatherer agent chooses the closest visible piece of food that is currently not being carried by anyone (and is not already in the agent's home base) and accelerates towards it. If no "uncarried" food can be found, the agent tries to find food carried by a member of the opposing team to accelerate towards. If no food is visible the agent sets his acceleration to a random vector to search for food. When it gets close enough to pick up a piece of food, it picks it up and carries it towards its home base corner for 20 time cycles, and drops it again. The gatherer must then rest for 10 time cycles before picking up another piece of food. During these 10 time cycles, the "exhausted" agent does not accelerate.
Field Summary | |
---|---|
protected boolean |
bottomRightTeam
Whether or not the agent is on the team with the home base in the bottom right-hand corner of the world |
protected int |
timeCarried
The amount of time the gatherer has been carrying a piece of food |
protected int |
timeToRest
The the amount of time needed to rest |
protected Vector |
towardsHome
The vector pointing in the direction of the agent's home base |
Fields inherited from class appletbots.Agent |
---|
accelerationVectorColor, maxAcceleration, sight, velocityVectorColor, world |
Fields inherited from class appletbots.WorldObject |
---|
color, mass, maxSpeed, size |
Constructor Summary | |
---|---|
Gatherer(int pickupDistance,
boolean bottomRightTeam,
int size,
int sight,
double maxSpeed,
double maxAcceleration)
Constructs a new Gatherer with the given parameters |
Method Summary | |
---|---|
protected Food |
chooseFood(boolean carried)
Selects closest visible food not already in home base |
protected void |
dropFood()
Attempts to drop any carried food |
protected Gatherer |
getNearestGatherer(boolean opponent)
Returns the nearest visible gatherer |
boolean |
isBottomRightTeam()
Returns whether or not the agent is on the team with the home base in the bottom right-hand corner of the world |
void |
observeWorld()
Observes the world, and follows the Gatherer Algorithm. |
protected void |
pickUp(CarriableObject item)
Picks up an object |
Methods inherited from class appletbots.CarrierAgent |
---|
drop, getInventory, getPickUpDistance, hasItem, hasItems |
Methods inherited from class appletbots.Agent |
---|
getAcceleration, getMaxAcceleration, getRandomAcceleration, getShowAcceleration, getShowVelocity, getSight, getVectorsToDraw, setAcceleration, setShowAcceleration, setShowVelocity, setWorld |
Methods inherited from class appletbots.WorldObject |
---|
collidedWith, getColor, getMass, getMaxSpeed, getSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean bottomRightTeam
protected int timeCarried
protected int timeToRest
protected Vector towardsHome
Constructor Detail |
---|
public Gatherer(int pickupDistance, boolean bottomRightTeam, int size, int sight, double maxSpeed, double maxAcceleration)
pickupDistance
- The distance from an object the agent must be to
pick up the objectbottomRightTeam
- Whether or not this agent is on the team moving
food to the bottom right corner of the worldsize
- The agent's radiussight
- The distance the agent can seemaxSpeed
- The maximum speed the agent can travelmaxAcceleration
- The maximum acceleration for this agentMethod Detail |
---|
public void observeWorld()
observeWorld
in class Agent
protected Food chooseFood(boolean carried)
carried
- Whether or not the food we are looking for is being
carried
protected Gatherer getNearestGatherer(boolean opponent)
opponent
- If true will return nearest visible opponent, otherwise nearest teammate
public boolean isBottomRightTeam()
protected void dropFood()
protected void pickUp(CarriableObject item)
pickUp
in class CarrierAgent
item
- The object to pick up
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |