|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSimpleTurtle
Turtle
Agent
Class that represents a general Agent. We are designing to offer more flexibility than one might expect to use.
Field Summary | |
protected static int |
MAXSPEED
class constant for top speed (max num steps can move in a timestep) |
Picture |
myPict
|
protected static double |
PROB_OF_STAY
class constant for probability of NOT turning |
protected static Random |
randNumGen
random number generator |
protected Simulation |
simulation
My simulation |
protected int |
speed
My current speed |
Constructor Summary | |
Agent(int x,
int y,
ModelDisplay modelDisplayer,
Simulation thisSim)
Constructor that takes the x and y and a model display to draw it on |
|
Agent(ModelDisplay modelDisplayer,
Simulation thisSim)
Constructor that takes the model display (the original position will be randomly assigned) |
Method Summary | |
void |
act()
Method to act during a time step Default is to pick a random direction and move some random amount up to top speed |
void |
act(int t)
act() with a timestep |
int |
countInRange(double range,
LinkedList list)
Method to count the number of agents within the range that are on the given list |
void |
die()
Method that handles when an Agent dies |
Agent |
getClosest(double distance,
LinkedList list)
Method to get the closest agent within the passed distance to this agent but NOT this agent. |
Simulation |
getSimulation()
|
int |
getSpeed()
|
void |
init(Simulation thisSim)
Method to initialize the new wolf object |
void |
setSpeed(int velocity)
Accessors |
Methods inherited from class Turtle |
square |
Methods inherited from class SimpleTurtle |
backward, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getPicture, getShellColor, getShowInfo, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setPicture, setShellColor, setShowInfo, setVisible, show, toString, turn, turnLeft, turnRight, turnToFace, turnToFace, updateDisplay |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public Picture myPict
protected static final double PROB_OF_STAY
protected static final int MAXSPEED
protected static Random randNumGen
protected int speed
protected Simulation simulation
Constructor Detail |
public Agent(ModelDisplay modelDisplayer, Simulation thisSim)
modelDisplayer
- thing that displays the modelthisSim
- my simulationpublic Agent(int x, int y, ModelDisplay modelDisplayer, Simulation thisSim)
x
- the starting x positiony
- the starting y positionmodelDisplayer
- the thing that displays the modelthisSim
- my simulationMethod Detail |
public void setSpeed(int velocity)
public int getSpeed()
public Simulation getSimulation()
public void init(Simulation thisSim)
public void die()
public Agent getClosest(double distance, LinkedList list)
distance
- the distance to look withinlist
- the list of agents to look at
public int countInRange(double range, LinkedList list)
range
- the number of steps within which to consider agentslist
- of agents to consider
public void act(int t)
public void act()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |