|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectappletbots.WorldObject
appletbots.Agent
public abstract class Agent
This class represents an Agent in a appletbots world.
Field Summary | |
---|---|
protected java.awt.Color |
accelerationVectorColor
The color to paint the acceleration vector |
protected double |
maxAcceleration
The maximum amount of acceleration for this agent |
protected int |
sight
The distance the agent can see |
protected java.awt.Color |
velocityVectorColor
The color to paint the velocity vector |
protected World |
world
The world in which the agent exists |
Fields inherited from class appletbots.WorldObject |
---|
color, mass, maxSpeed, size |
Constructor Summary | |
---|---|
Agent()
Constructs a new agent with the following default values: size = 5 sight = 60 maxSpeed = 5.0 maxAcceleration = 3.0 |
|
Agent(int size,
int sight,
double maxSpeed,
double maxAcceleration)
Constructs an agent with the given parameters |
Method Summary | |
---|---|
Vector |
getAcceleration()
Returns the agent's acceleration. |
double |
getMaxAcceleration()
Returns the agent's maximum acceleration |
Vector |
getRandomAcceleration()
Returns a random acceleration vector |
boolean |
getShowAcceleration()
Returns whether or not the agent's acceleration vector will be drawn |
boolean |
getShowVelocity()
Returns whether or not the agent's velocity vector will be drawn |
int |
getSight()
Returns the distance this agent can see |
VectorToDraw[] |
getVectorsToDraw()
Returns an array of vectors that should be drawn at the time this agent is painted |
abstract void |
observeWorld()
The method invoked to allow the agent to observe the world and optionally modify his acceleration to try to achieve a goal. |
protected void |
setAcceleration(Vector acceleration)
Sets the agent's acceleration vector. |
void |
setShowAcceleration(boolean showAcceleration)
Sets a flag to let the agent know whether or not to draw his acceleration vector |
void |
setShowVelocity(boolean showVelocity)
Sets a flag to let the agent know whether or not to draw his velocity vector |
void |
setWorld(World world)
Tells the agent what world he is in. |
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 int sight
protected double maxAcceleration
protected World world
protected java.awt.Color velocityVectorColor
protected java.awt.Color accelerationVectorColor
Constructor Detail |
---|
public Agent()
public Agent(int size, int sight, double maxSpeed, double maxAcceleration)
size
- 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 int getSight()
public void setWorld(World world)
world
- The world the agent exists inpublic final Vector getRandomAcceleration()
public Vector getAcceleration()
protected void setAcceleration(Vector acceleration)
acceleration
- The agent's accelerationpublic double getMaxAcceleration()
public VectorToDraw[] getVectorsToDraw()
public void setShowAcceleration(boolean showAcceleration)
showAcceleration
- Whether or not to draw the acceleration vectorpublic boolean getShowAcceleration()
public void setShowVelocity(boolean showVelocity)
showVelocity
- Whether or not to draw the velocity vectorpublic boolean getShowVelocity()
public abstract void observeWorld()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |