org.primordion.xholon.base
Class Turtle

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.XholonWithPorts
          extended byorg.primordion.xholon.base.Turtle
All Implemented Interfaces:
ITurtle, IXholon
Direct Known Subclasses:
BugStupidModel16nl, TurtleExample1, WolfSheep

public class Turtle
extends XholonWithPorts
implements ITurtle

A turtle is an agent in the turtle mechanism. The turtle mechanism is based on Logo and NetLogo. The abbreviated version of a turtle command (ex: fd bk rt lt) should be used instead of the unabbreviated command.

Since:
0.5 (Created on February 24, 2007)
Author:
Ken Webb
See Also:
NetLogo website http://ccl.northwestern.edu/netlogo/

Field Summary
 int color
           
 double heading
           
 boolean isHidden
           
 int penMode
           
 double xcor
           
 double ycor
           
 
Fields inherited from class org.primordion.xholon.base.XholonWithPorts
port
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.ITurtle
COMMANDID_NONE, FILTERID_NONE, PENMODE_DOWN, PENMODE_ERASE, PENMODE_UP, WHENMOVED_INIT
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Constructor Summary
Turtle()
           
 
Method Summary
 void aggregate(double amount)
          Aggregate by keeping a count of the number of individuals of a given "breed".
 void back(double distance)
          Move back a given distance.
 void beep()
          Make a single short beep sound.
 void bk(double distance)
          Move back a given distance.
 boolean canMove(double distance)
          Can this turtle legally move the specified distance, given its current heading?
 void die()
          Remove yourself permanently from the gene pool.
 double distance(IXholon turtleOrPatch)
          Return the distance between self and the specified turtle or patch.
 double distancexy(double x, double y)
          Return the distance between yourself and the specified x, y coordinates.
 double downhill()
          "Return the turtle heading in the direction of the minimum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."
 double downhill4()
          "Return the turtle heading in the direction of the minimum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."
 double dx()
          Returns the delta in the x direction if the turtle moved one unit along its current heading.
 double dy()
          Returns the delta in the y direction if the turtle moved one unit along its current heading.
 void face(IXholon turtleOrPatch)
          Turn to face the specified turtle or patch.
 void facexy(double x, double y)
          Turn to face the specified x, y coordinates.
 void fd(double distance)
          Move forward a given distance.
 void forward(double distance)
          Move forward a given distance.
 int getBreed()
          Get the turtle's breed id.
 int getColor()
          Get the turtle's color.
 double getHeading()
          Get the turtle's heading.
 boolean getIsHidden()
          Get the turtle's hide status.
 java.lang.String getLabel()
          Get the turtle's label, a String that helps to identify it.
 int getMaxPxcor()
          Return the maximum Patch x coordinate.
 int getMaxPycor()
          Return the maximum Patch y coordinate.
 int getMinPxcor()
          Return the minimum Patch x coordinate.
 int getMinPycor()
          Return the minimum Patch y coordinate.
 int getPcolor()
          Get the patch's pcolor.
 int getPenMode()
          Get the turtle's pen mode.
 java.lang.String getPlabel()
          Get the patch's label, a String that helps to identify it.
 int getPxcor()
          Get the patch's x coordinate.
 int getPycor()
          Get the patch's y coordinate.
 int getWho()
          Get the turtle's who id.
 int getWorldHeight()
          Return the height of the world (the grid height).
 int getWorldWidth()
          Return the width of the world (the grid width).
 double getXcor()
          Get the turtle's x coordinate.
 double getYcor()
          Get the turtle's y coordinate.
 boolean hasAlreadyMoved()
          Has this turtle already moved this time step? This method is required to prevent turtles from moving multiple times in the same time step, which would happen when a turtle moves to a patch that hasn't yet been reached in the tree traversal this time step.
 void hatch(int numTurtles, int commandId)
          Hatch a specified number of new turtles, each identical to this turtle.
 void hideTurtle()
          Hide from view.
 void home()
          Go home, by returning to the home coordinates.
 void ht()
          Hide from view.
 java.util.Vector inCone(double distance, double angle)
          Return agents that fall within a cone defined by the distance and angle .
 void initWhenMoved(int when)
          Initialize the whenMoved variable.
 java.util.Vector inRadius(int radius)
          Return a list of all neighbors (turtles) within the specified radius.
 java.util.Vector inRadius(int radius, int filterId)
          Return a list of all neighbors (turtles) within the specified radius.
 void jump(double distance)
          Jump forward a given distance, without effecting any intervening patches or turtles.
 void jump(IPatch aPatch)
          Jump directly to the specified patch.
 void jump(ITurtle aTurtle)
          Jump directly to the patch that the specified turtle is currently in.
 void left(double angle)
          Turn left a given angle.
 IXholon lineBresenham(int x0, int y0, int x1, int y1, int colr)
          Draw a line using the Bresenham algorithm.
 void lt(double angle)
          Turn left a given angle.
 java.util.Vector neighbors()
          Return the 8 surrounding neighbor patches.
 java.util.Vector neighbors4()
          Return the 4 surrounding neighbor patches.
 java.util.Vector otherTurtlesHere()
          Return all other turtles that are also currently located at this turtle's patch.
 IPatch patchAhead(double distance)
          Return the single patch that is the given distance along the turtle's current heading.
 IPatch patchAt(int dx, int dy)
          Return the single patch at the specified x and y relative distance.
 IPatch patchAtHeadingAndDistance(double heading, double distance)
          Return the single patch at the specified absolute heading and relative distance.
 IPatch patchHere()
          Return the patch that the turtle is currently on.
 IPatch patchLeftAndAhead(double distance, double angle)
          Return the single patch that is the given distance from the turtle, in the direction turned left the given angle from the turtle's current heading.
 IPatch patchRightAndAhead(double distance, double angle)
          Return the single patch that is the given distance from the turtle, in the direction turned right the given angle from the turtle's current heading.
 void pd()
          Set the pen down, so it is able to draw.
 void pe()
          Set the pen to erase.
 void penDown()
          Set the pen down, so it is able to draw.
 void penErase()
          Set the pen to erase.
 void penUp()
          Set the pen up, so it is unable to draw.
 void pu()
          Set the pen up, so it is unable to draw.
 void right(double angle)
          Turn right a given angle.
 void rt(double angle)
          Turn right a given angle.
 void setBreed(int breed)
          Set or change the turtle's breed id.
 void setColor(int color)
          Set the turtle's color.
 void setHeading(double heading)
          Set the turtle's heading.
 void setIsHidden(boolean isHidden)
          Set the turtle's hide status.
 void setLabel(java.lang.String label)
          Set or change the turtle's label.
 void setPcolor(int pcolor)
          Set the patch's pcolor.
 void setPenMode(int penMode)
          Set the turtle's pen mode.
 void setPlabel(java.lang.String plabel)
          Set or change the patch's label.
 void setPxcor(int pxcor)
          Set the patch's x coordinate.
 void setPycor(int pycor)
          Set the patch's y coordinate.
 void setWho(int who)
          Set the turtle's who id.
 void setXcor(double xcor)
          Set the turtle's x coordinate.
 void setxy(double x, double y)
          Set the turtle's x and y coordinates, and move to that location.
 void setYcor(double ycor)
          Set the turtle's y coordinate.
 void showTurtle()
          Show in the viewer.
 void st()
          Show in the viewer.
 void stamp()
          Leave an inprint or stamp of self at the current patch.
 void stampErase()
          Erase any inprint or stamp at the current patch.
 java.lang.String toString()
           
 double towards(IXholon turtleOrPatch)
          Return the heading between self and the specified turtle or patch.
 double towardsxy(double x, double y)
          Return the heading between self and the specified x, y coordinates.
 java.util.Vector turtlesAt(int dx, int dy)
          Return the turtles located at the single patch at the specified x and y relative distance.
 java.util.Vector turtlesHere()
          Return the turtles located at the current patch.
 java.util.Vector turtlesOn()
          Return the turtles that are on the given patch or patches, or standing on the same patch as the given turtle or turtles.
 double uphill()
          "Return the turtle heading in the direction of the maximum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."
 double uphill4()
          "Return the turtle heading in the direction of the maximum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."
 java.util.Vector with(java.util.Vector vIn, int filterId)
          Filters the input vector to produce an output vector.
 
Methods inherited from class org.primordion.xholon.base.XholonWithPorts
configure, getMaxPorts, getPort, initialize, isActiveObject, isBound, isContainer, isPassiveObject, postConfigure, setMaxPorts, setPorts, terminate
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isExternal, isInternal, isLeaf, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 

Field Detail

color

public int color

heading

public double heading

isHidden

public boolean isHidden

penMode

public int penMode

xcor

public double xcor

ycor

public double ycor
Constructor Detail

Turtle

public Turtle()
Method Detail

back

public void back(double distance)
Description copied from interface: ITurtle
Move back a given distance.

Specified by:
back in interface ITurtle
Parameters:
distance - A distance measured in units.

bk

public void bk(double distance)
Description copied from interface: ITurtle
Move back a given distance. This method implements the same functionality as back().

Specified by:
bk in interface ITurtle
Parameters:
distance - A distance measured in units.

beep

public void beep()
Description copied from interface: ITurtle
Make a single short beep sound.

Specified by:
beep in interface ITurtle

canMove

public boolean canMove(double distance)
Description copied from interface: ITurtle
Can this turtle legally move the specified distance, given its current heading?

Specified by:
canMove in interface ITurtle
Parameters:
distance - A distance measured in units.
Returns:
true or false

die

public void die()
Description copied from interface: ITurtle
Remove yourself permanently from the gene pool.

Specified by:
die in interface ITurtle

distance

public double distance(IXholon turtleOrPatch)
Description copied from interface: ITurtle
Return the distance between self and the specified turtle or patch.

Specified by:
distance in interface ITurtle
Parameters:
turtleOrPatch - A turtle or patch object.
Returns:
A distance in units.

distancexy

public double distancexy(double x,
                         double y)
Description copied from interface: ITurtle
Return the distance between yourself and the specified x, y coordinates.

Specified by:
distancexy in interface ITurtle
Parameters:
x - A global x coordinate.
y - A global y coordinate.
Returns:
A distance in units.

downhill

public double downhill()
Description copied from interface: ITurtle
"Return the turtle heading in the direction of the minimum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."

Specified by:
downhill in interface ITurtle
Returns:
An angle between 0 and 359 degrees.

downhill4

public double downhill4()
Description copied from interface: ITurtle
"Return the turtle heading in the direction of the minimum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."

Specified by:
downhill4 in interface ITurtle
Returns:
An angle between 0 and 359 degrees.

dx

public double dx()
Description copied from interface: ITurtle
Returns the delta in the x direction if the turtle moved one unit along its current heading.

Specified by:
dx in interface ITurtle

dy

public double dy()
Description copied from interface: ITurtle
Returns the delta in the y direction if the turtle moved one unit along its current heading.

Specified by:
dy in interface ITurtle

face

public void face(IXholon turtleOrPatch)
Description copied from interface: ITurtle
Turn to face the specified turtle or patch.

Specified by:
face in interface ITurtle
Parameters:
turtleOrPatch - A turtle or patch object.

facexy

public void facexy(double x,
                   double y)
Description copied from interface: ITurtle
Turn to face the specified x, y coordinates.

Specified by:
facexy in interface ITurtle
Parameters:
x - A global x coordinate.
y - A global y coordinate.

forward

public void forward(double distance)
Description copied from interface: ITurtle
Move forward a given distance.

Specified by:
forward in interface ITurtle
Parameters:
distance - A distance measured in units.

fd

public void fd(double distance)
Description copied from interface: ITurtle
Move forward a given distance. This method implements the same functionality as forward().

Specified by:
fd in interface ITurtle
Parameters:
distance - A distance measured in units.

hatch

public void hatch(int numTurtles,
                  int commandId)
Description copied from interface: ITurtle
Hatch a specified number of new turtles, each identical to this turtle.

Specified by:
hatch in interface ITurtle
Parameters:
numTurtles - The number of new turtles to hatch.
commandId - The ID of a set of turtle commands that can be executed. by calling performActivity(int commandId) on each new turtle.

hideTurtle

public void hideTurtle()
Description copied from interface: ITurtle
Hide from view.

Specified by:
hideTurtle in interface ITurtle

ht

public void ht()
Description copied from interface: ITurtle
Hide from view. This method implements the same functionality as hideTurtle().

Specified by:
ht in interface ITurtle

home

public void home()
Description copied from interface: ITurtle
Go home, by returning to the home coordinates.

Specified by:
home in interface ITurtle

inCone

public java.util.Vector inCone(double distance,
                               double angle)
Description copied from interface: ITurtle
Return agents that fall within a cone defined by the distance and angle .

Specified by:
inCone in interface ITurtle
Parameters:
distance - A distance measured in units.
angle - An angle measured in degrees.
Returns:
A collection of ITurtle or IPatch instances.

inRadius

public java.util.Vector inRadius(int radius)
Description copied from interface: ITurtle
Return a list of all neighbors (turtles) within the specified radius. This works for a torus where each cell has 8 neighbors.

Specified by:
inRadius in interface ITurtle
Parameters:
radius - Distance from the current patch. The current patch is a radius of 0 from itself.
Returns:
A vector containing zero or more turtles.

inRadius

public java.util.Vector inRadius(int radius,
                                 int filterId)
Description copied from interface: ITurtle
Return a list of all neighbors (turtles) within the specified radius. This works for a torus where each cell has 8 neighbors.

Specified by:
inRadius in interface ITurtle
Parameters:
radius - Distance from the current patch. The current patch is a radius of 0 from itself.
filterId - An ID that can be used by performBooleanActivity() to select a specific filter.
Returns:
A vector containing zero or more gridCells.

jump

public void jump(double distance)
Description copied from interface: ITurtle
Jump forward a given distance, without effecting any intervening patches or turtles.

Specified by:
jump in interface ITurtle
Parameters:
distance - A distance measured in units.

jump

public void jump(IPatch aPatch)
Description copied from interface: ITurtle
Jump directly to the specified patch.

Specified by:
jump in interface ITurtle
Parameters:
aPatch - A patch.

jump

public void jump(ITurtle aTurtle)
Description copied from interface: ITurtle
Jump directly to the patch that the specified turtle is currently in.

Specified by:
jump in interface ITurtle
Parameters:
aTurtle - A turtle.

left

public void left(double angle)
Description copied from interface: ITurtle
Turn left a given angle.

Specified by:
left in interface ITurtle
Parameters:
angle - An angle measured in degrees.

lt

public void lt(double angle)
Description copied from interface: ITurtle
Turn left a given angle. This method implements the same functionality as left().

Specified by:
lt in interface ITurtle
Parameters:
angle - A relative angle measured in degrees.

neighbors

public java.util.Vector neighbors()
Description copied from interface: ITurtle
Return the 8 surrounding neighbor patches.

Specified by:
neighbors in interface ITurtle
Returns:
A collection of IPatch instances.

neighbors4

public java.util.Vector neighbors4()
Description copied from interface: ITurtle
Return the 4 surrounding neighbor patches.

Specified by:
neighbors4 in interface ITurtle
Returns:
A collection of IPatch instances.

otherTurtlesHere

public java.util.Vector otherTurtlesHere()
Description copied from interface: ITurtle
Return all other turtles that are also currently located at this turtle's patch.

Specified by:
otherTurtlesHere in interface ITurtle
Returns:
A collection of ITurtle instances.

patchAhead

public IPatch patchAhead(double distance)
Description copied from interface: ITurtle
Return the single patch that is the given distance along the turtle's current heading.

Specified by:
patchAhead in interface ITurtle
Parameters:
distance - A distance measured in units.
Returns:
An IPatch instance.

patchAt

public IPatch patchAt(int dx,
                      int dy)
Description copied from interface: ITurtle
Return the single patch at the specified x and y relative distance.

Specified by:
patchAt in interface ITurtle
Parameters:
dx - A relative distance in the x direction, in patches.
dy - A relative distance in the y direction, in patches.
Returns:
A patch, or null.

patchAtHeadingAndDistance

public IPatch patchAtHeadingAndDistance(double heading,
                                        double distance)
Description copied from interface: ITurtle
Return the single patch at the specified absolute heading and relative distance.

Specified by:
patchAtHeadingAndDistance in interface ITurtle
Parameters:
heading - An absolute angle measured in degrees.
distance - A distance measured in units.
Returns:
A patch, or null.

patchHere

public IPatch patchHere()
Description copied from interface: ITurtle
Return the patch that the turtle is currently on.

Specified by:
patchHere in interface ITurtle
Returns:
A patch.

patchLeftAndAhead

public IPatch patchLeftAndAhead(double distance,
                                double angle)
Description copied from interface: ITurtle
Return the single patch that is the given distance from the turtle, in the direction turned left the given angle from the turtle's current heading.

Specified by:
patchLeftAndAhead in interface ITurtle
Parameters:
distance - A distance measured in units.
angle - An angle measured in degrees.
Returns:
A patch, or null.

patchRightAndAhead

public IPatch patchRightAndAhead(double distance,
                                 double angle)
Description copied from interface: ITurtle
Return the single patch that is the given distance from the turtle, in the direction turned right the given angle from the turtle's current heading.

Specified by:
patchRightAndAhead in interface ITurtle
Parameters:
distance - A distance measured in units.
angle - An angle measured in degrees.
Returns:
A patch, or null.

penDown

public void penDown()
Description copied from interface: ITurtle
Set the pen down, so it is able to draw.

Specified by:
penDown in interface ITurtle

pd

public void pd()
Description copied from interface: ITurtle
Set the pen down, so it is able to draw. This method implements the same functionality as penDown().

Specified by:
pd in interface ITurtle

penErase

public void penErase()
Description copied from interface: ITurtle
Set the pen to erase.

Specified by:
penErase in interface ITurtle

pe

public void pe()
Description copied from interface: ITurtle
Set the pen to erase. This method implements the same functionality as penErase().

Specified by:
pe in interface ITurtle

penUp

public void penUp()
Description copied from interface: ITurtle
Set the pen up, so it is unable to draw.

Specified by:
penUp in interface ITurtle

pu

public void pu()
Description copied from interface: ITurtle
Set the pen up, so it is unable to draw. This method implements the same functionality as penUp().

Specified by:
pu in interface ITurtle

right

public void right(double angle)
Description copied from interface: ITurtle
Turn right a given angle.

Specified by:
right in interface ITurtle
Parameters:
angle - An angle measured in degrees.

rt

public void rt(double angle)
Description copied from interface: ITurtle
Turn right a given angle. This method implements the same functionality as right().

Specified by:
rt in interface ITurtle
Parameters:
angle - A relative angle measured in degrees.

setxy

public void setxy(double x,
                  double y)
Description copied from interface: ITurtle
Set the turtle's x and y coordinates, and move to that location.

Specified by:
setxy in interface ITurtle
Parameters:
x - New value for the turtle's x coordinate.
y - New value for the turtle's y coordinate.

showTurtle

public void showTurtle()
Description copied from interface: ITurtle
Show in the viewer.

Specified by:
showTurtle in interface ITurtle

st

public void st()
Description copied from interface: ITurtle
Show in the viewer. This method implements the same functionality as showTurtle().

Specified by:
st in interface ITurtle

stamp

public void stamp()
Description copied from interface: ITurtle
Leave an inprint or stamp of self at the current patch.

Specified by:
stamp in interface ITurtle

stampErase

public void stampErase()
Description copied from interface: ITurtle
Erase any inprint or stamp at the current patch.

Specified by:
stampErase in interface ITurtle

towards

public double towards(IXholon turtleOrPatch)
Description copied from interface: ITurtle
Return the heading between self and the specified turtle or patch.

Specified by:
towards in interface ITurtle
Parameters:
turtleOrPatch - A turtle or patch object.
Returns:
A A heading angle in degrees.

towardsxy

public double towardsxy(double x,
                        double y)
Description copied from interface: ITurtle
Return the heading between self and the specified x, y coordinates.

Specified by:
towardsxy in interface ITurtle
Parameters:
x - A global x coordinate.
y - A global y coordinate.
Returns:
A heading angle in degrees.

turtlesAt

public java.util.Vector turtlesAt(int dx,
                                  int dy)
Description copied from interface: ITurtle
Return the turtles located at the single patch at the specified x and y relative distance.

Specified by:
turtlesAt in interface ITurtle
Parameters:
dx - A relative distance in the x direction, in patches.
dy - A relative distance in the y direction, in patches.
Returns:
A collection of ITurtle instances.

turtlesHere

public java.util.Vector turtlesHere()
Description copied from interface: ITurtle
Return the turtles located at the current patch.

Specified by:
turtlesHere in interface ITurtle
Returns:
A collection of ITurtle instances.

turtlesOn

public java.util.Vector turtlesOn()
Description copied from interface: ITurtle
Return the turtles that are on the given patch or patches, or standing on the same patch as the given turtle or turtles.

Specified by:
turtlesOn in interface ITurtle
Returns:
A collection of ITurtle instances.

uphill

public double uphill()
Description copied from interface: ITurtle
"Return the turtle heading in the direction of the maximum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."

Specified by:
uphill in interface ITurtle
Returns:
An angle between 0 and 359 degrees.

uphill4

public double uphill4()
Description copied from interface: ITurtle
"Return the turtle heading in the direction of the maximum value of the variable patch-variable, of the patches in a one-patch radius of the turtle."

Specified by:
uphill4 in interface ITurtle
Returns:
An angle between 0 and 359 degrees.

with

public java.util.Vector with(java.util.Vector vIn,
                             int filterId)
Description copied from interface: ITurtle
Filters the input vector to produce an output vector.

Specified by:
with in interface ITurtle
Parameters:
vIn - A collection of ITurtle instances.
Returns:
A filtered collection of ITurtle instances.

getBreed

public int getBreed()
Description copied from interface: ITurtle
Get the turtle's breed id.

Specified by:
getBreed in interface ITurtle

setBreed

public void setBreed(int breed)
Description copied from interface: ITurtle
Set or change the turtle's breed id. Warning: Use caution when changing the breed.

Specified by:
setBreed in interface ITurtle
Parameters:
breed - A breed id.

getColor

public int getColor()
Description copied from interface: ITurtle
Get the turtle's color.

Specified by:
getColor in interface ITurtle
Returns:
A color value, as defined in ITurtlePatchColor.

setColor

public void setColor(int color)
Description copied from interface: ITurtle
Set the turtle's color. NetLogo: set color value

Specified by:
setColor in interface ITurtle
Parameters:
color - A color value, as defined in ITurtlePatchColor.

getHeading

public double getHeading()
Description copied from interface: ITurtle
Get the turtle's heading.

Specified by:
getHeading in interface ITurtle
Returns:
An absolute angle measured in degrees.

setHeading

public void setHeading(double heading)
Description copied from interface: ITurtle
Set the turtle's heading. NetLogo: set heading value

Specified by:
setHeading in interface ITurtle
Parameters:
heading - An absolute angle measured in degrees.

getIsHidden

public boolean getIsHidden()
Description copied from interface: ITurtle
Get the turtle's hide status. Is it hidden or visible?

Specified by:
getIsHidden in interface ITurtle
Returns:
true or false

setIsHidden

public void setIsHidden(boolean isHidden)
Description copied from interface: ITurtle
Set the turtle's hide status.

Specified by:
setIsHidden in interface ITurtle
Parameters:
isHidden - hidden (true) or visible (false)

getLabel

public java.lang.String getLabel()
Description copied from interface: ITurtle
Get the turtle's label, a String that helps to identify it.

Specified by:
getLabel in interface ITurtle
Returns:
A label.

setLabel

public void setLabel(java.lang.String label)
Description copied from interface: ITurtle
Set or change the turtle's label. Warning: Use caution when changing the label.

Specified by:
setLabel in interface ITurtle
Parameters:
label -

getPenMode

public int getPenMode()
Description copied from interface: ITurtle
Get the turtle's pen mode.

Specified by:
getPenMode in interface ITurtle
Returns:
A pen mode, one of PENMODE_UP, PENMODE_DOWN, or PENMODE_ERASE.

setPenMode

public void setPenMode(int penMode)
Description copied from interface: ITurtle
Set the turtle's pen mode.

Specified by:
setPenMode in interface ITurtle
Parameters:
penMode - A pen mode, one of PENMODE_UP, PENMODE_DOWN, or PENMODE_ERASE.

getWho

public int getWho()
Description copied from interface: ITurtle
Get the turtle's who id.

Specified by:
getWho in interface ITurtle
Returns:
A who id.

setWho

public void setWho(int who)
Description copied from interface: ITurtle
Set the turtle's who id. Warning: Use caution when changing the who id.

Specified by:
setWho in interface ITurtle
Parameters:
who - A who id.

getXcor

public double getXcor()
Description copied from interface: ITurtle
Get the turtle's x coordinate.

Specified by:
getXcor in interface ITurtle
Returns:
The xcor value.

setXcor

public void setXcor(double xcor)
Description copied from interface: ITurtle
Set the turtle's x coordinate.

Specified by:
setXcor in interface ITurtle
Parameters:
xcor - An xcor value.

getYcor

public double getYcor()
Description copied from interface: ITurtle
Get the turtle's y coordinate.

Specified by:
getYcor in interface ITurtle
Returns:
The ycor value.

setYcor

public void setYcor(double ycor)
Description copied from interface: ITurtle
Set the turtle's y coordinate.

Specified by:
setYcor in interface ITurtle
Parameters:
ycor - An ycor value.

getPcolor

public int getPcolor()
Description copied from interface: ITurtle
Get the patch's pcolor.

Specified by:
getPcolor in interface ITurtle
Returns:
A pcolor value, as defined in ITurtlePatchColor.

setPcolor

public void setPcolor(int pcolor)
Description copied from interface: ITurtle
Set the patch's pcolor. NetLogo: set pcolor value

Specified by:
setPcolor in interface ITurtle
Parameters:
pcolor - A pcolor value, as defined in ITurtlePatchColor.

getPlabel

public java.lang.String getPlabel()
Description copied from interface: ITurtle
Get the patch's label, a String that helps to identify it.

Specified by:
getPlabel in interface ITurtle
Returns:
A label.

setPlabel

public void setPlabel(java.lang.String plabel)
Description copied from interface: ITurtle
Set or change the patch's label. Warning: Use caution when changing the label.

Specified by:
setPlabel in interface ITurtle

getPxcor

public int getPxcor()
Description copied from interface: ITurtle
Get the patch's x coordinate.

Specified by:
getPxcor in interface ITurtle
Returns:
The pxcor value.

setPxcor

public void setPxcor(int pxcor)
Description copied from interface: ITurtle
Set the patch's x coordinate.

Specified by:
setPxcor in interface ITurtle

getPycor

public int getPycor()
Description copied from interface: ITurtle
Get the patch's y coordinate.

Specified by:
getPycor in interface ITurtle
Returns:
The pycor value.

setPycor

public void setPycor(int pycor)
Description copied from interface: ITurtle
Set the patch's y coordinate.

Specified by:
setPycor in interface ITurtle

getMaxPxcor

public int getMaxPxcor()
Description copied from interface: ITurtle
Return the maximum Patch x coordinate.

Specified by:
getMaxPxcor in interface ITurtle
Returns:
A Patch coordinate.

getMaxPycor

public int getMaxPycor()
Description copied from interface: ITurtle
Return the maximum Patch y coordinate.

Specified by:
getMaxPycor in interface ITurtle
Returns:
A Patch coordinate.

getMinPxcor

public int getMinPxcor()
Description copied from interface: ITurtle
Return the minimum Patch x coordinate.

Specified by:
getMinPxcor in interface ITurtle
Returns:
A Patch coordinate.

getMinPycor

public int getMinPycor()
Description copied from interface: ITurtle
Return the minimum Patch y coordinate.

Specified by:
getMinPycor in interface ITurtle
Returns:
A Patch coordinate.

getWorldWidth

public int getWorldWidth()
Description copied from interface: ITurtle
Return the width of the world (the grid width).

Specified by:
getWorldWidth in interface ITurtle
Returns:
The width in Patch units.

getWorldHeight

public int getWorldHeight()
Description copied from interface: ITurtle
Return the height of the world (the grid height).

Specified by:
getWorldHeight in interface ITurtle
Returns:
The height in Patch units.

hasAlreadyMoved

public boolean hasAlreadyMoved()
Description copied from interface: ITurtle
Has this turtle already moved this time step? This method is required to prevent turtles from moving multiple times in the same time step, which would happen when a turtle moves to a patch that hasn't yet been reached in the tree traversal this time step. It would perform its action, move to a new patch postion, and subsequently be re-executed as a child of the second patch.

Specified by:
hasAlreadyMoved in interface ITurtle

initWhenMoved

public void initWhenMoved(int when)
Description copied from interface: ITurtle
Initialize the whenMoved variable. This is intended for internal use only.

Specified by:
initWhenMoved in interface ITurtle
Parameters:
when - A time step, normally WHENMOVED_INIT (-1).

aggregate

public void aggregate(double amount)
Description copied from interface: ITurtle
Aggregate by keeping a count of the number of individuals of a given "breed".

Specified by:
aggregate in interface ITurtle
Parameters:
amount - The amount to increment or decrement the current population count. The amount can be a positive (increment) or negative (decrement) number.

lineBresenham

public IXholon lineBresenham(int x0,
                             int y0,
                             int x1,
                             int y1,
                             int colr)
Draw a line using the Bresenham algorithm.

Parameters:
x0 - X coordinate, start of line.
y0 - Y coordinate, start of line.
x1 - X coordinate, end of line.
y1 - Y coordinate, end of line.
colr - The color to set each patch along the line.
Returns:
The patch that the turtle has moved to, or the turtle's current patch if it is unable to move there.
See Also:
http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html

toString

public java.lang.String toString()
Overrides:
toString in class Xholon