Class Wolf

java.lang.Object
  extended by SimpleTurtle
      extended by Turtle
          extended by Wolf
Direct Known Subclasses:
HungryWolf

public class Wolf
extends Turtle

Class that represents a wolf. The wolf class tracks all the living wolves with a linked list.

Author:
Barb Ericson ericson@cc.gatech.edu

Field Summary
static double ATTACK_RANGE
          class constant for how close before wolf can attack
static Color GRAY
          class constant for the color
static int MAX_SPEED
          class constant for top speed (max num steps can move in a timestep)
static double PROB_OF_STAY
          class constant for probability of NOT turning
protected static Random randNumGen
          random number generator
static double SMELL_RANGE
          class constant for how far wolf can smell
 
Constructor Summary
Wolf(int x, int y, ModelDisplay modelDisplayer, WolfDeerSimulation thisSim)
          Constructor that takes the x and y and a model display to draw it on
Wolf(ModelDisplay modelDisplayer, WolfDeerSimulation 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 pick a random direction and move some random amount up to top speed
 AgentNode getClosest(double distance, AgentNode list)
          Method to get the closest deer within the passed distance to this wolf.
 WolfDeerSimulation getSimulation()
          Method to get the simulation
 void init(WolfDeerSimulation thisSim)
          Method to initialize the new wolf object
 
Methods inherited from class SimpleTurtle
backward, backward, clearPath, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getHeight, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getPicture, getShellColor, getShowInfo, getWidth, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setHeight, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setPicture, setShellColor, setShowInfo, setVisible, setWidth, 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

GRAY

public static final Color GRAY
class constant for the color


PROB_OF_STAY

public static final double PROB_OF_STAY
class constant for probability of NOT turning

See Also:
Constant Field Values

MAX_SPEED

public static final int MAX_SPEED
class constant for top speed (max num steps can move in a timestep)

See Also:
Constant Field Values

SMELL_RANGE

public static final double SMELL_RANGE
class constant for how far wolf can smell

See Also:
Constant Field Values

ATTACK_RANGE

public static final double ATTACK_RANGE
class constant for how close before wolf can attack

See Also:
Constant Field Values

randNumGen

protected static Random randNumGen
random number generator

Constructor Detail

Wolf

public Wolf(ModelDisplay modelDisplayer,
            WolfDeerSimulation thisSim)
Constructor that takes the model display (the original position will be randomly assigned)

Parameters:
modelDisplayer - thing that displays the model
thisSim - my simulation

Wolf

public Wolf(int x,
            int y,
            ModelDisplay modelDisplayer,
            WolfDeerSimulation thisSim)
Constructor that takes the x and y and a model display to draw it on

Parameters:
x - the starting x position
y - the starting y position
modelDisplayer - the thing that displays the model
thisSim - my simulation
Method Detail

getSimulation

public WolfDeerSimulation getSimulation()
Method to get the simulation

Returns:
the simulation

init

public void init(WolfDeerSimulation thisSim)
Method to initialize the new wolf object

Parameters:
thisSim - the simulation

getClosest

public AgentNode getClosest(double distance,
                            AgentNode list)
Method to get the closest deer within the passed distance to this wolf. We'll search the input list of the kind of objects to compare to.

Parameters:
distance - the distance to look within
list - the list of agents to look at
Returns:
the closest agent in the given distance or null

act

public void act()
Method to act during a time step pick a random direction and move some random amount up to top speed