public class Turtle extends XholonWithPorts implements ITurtle
NetLogo website http://ccl.northwestern.edu/netlogo/
,
Serialized FormModifier and Type | Field and Description |
---|---|
int |
color |
double |
heading |
boolean |
isHidden |
int |
penMode |
double |
xcor |
double |
ycor |
port
COMMANDID_NONE, FILTERID_NONE, PENMODE_DOWN, PENMODE_ERASE, PENMODE_UP, WHENMOVED_INIT
DEFAULT_SIZE_MSG_Q, DEFAULT_SIZE_SYSTEM_MSG_Q, GETNAME_DEFAULT, GETNAME_LOCALPART_ID, GETNAME_NOROLENAME, GETNAME_ROLENAME_OR_CLASSNAME, GETNAME_ROLENAMESEP_, GETNAME_SIZE_TEMPLATE, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx, XHOLON_ID_DEFAULT, XHOLON_ID_NULL
Constructor and Description |
---|
Turtle() |
Modifier and Type | Method and Description |
---|---|
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.
|
IAgentSet |
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.
|
IAgentSet |
inRadius(int radius)
Return a list of all neighbors (turtles) within the specified radius.
|
IAgentSet |
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.
|
IAgentSet |
neighbors()
Return the 8 surrounding neighbor patches.
|
IAgentSet |
neighbors4()
Return the 4 surrounding neighbor patches.
|
IAgentSet |
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()
Search for instances of Xholon with ports that reference this instance.
|
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.
|
IAgentSet |
turtlesAt(int dx,
int dy)
Return the turtles located at the single patch at the specified x and y relative distance.
|
IAgentSet |
turtlesHere()
Return the turtles located at the current patch.
|
IAgentSet |
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."
|
IAgentSet |
with(IAgentSet asIn,
int filterId)
Filters the input vector to produce an output vector.
|
configure, configurePorts, getPort, getPort, initialize, isActiveObject, isBound, isContainer, isPassiveObject, postConfigure, setPort, setPort, setPorts, terminate
act, actNr, appendChild, appendChild, appendChild, appendsOwnChildren, bindPorts, cleanup, compareTo, configure, consoleLog, decVal, decVal, depth, doAction, equals, findFirstChildWithXhClass, findFirstChildWithXhClass, forwardMessage, forwardSyncMessage, getActionList, getAllPorts, getAnnotation, getApp, getAttributeNodeXh, getAttributeXh, getChildNodes, getClassNode, getClassNode, getFactory, getFirstChild, getFirstSibling, getId, getInteraction, getInteractionsEnabled, getIQueueImplName, getLastChild, getLastSibling, getLogger, getMsgQ, getName, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumLevels, getNumSiblings, getParentNode, getPreviousSibling, getRoleName, getRootNode, getSelfAndSiblings, getSelfAndSiblingsIndex, getService, getSiblings, getSystemMsgQ, getUid, getUri, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXholon2Xml, getXhType, getXml2Xholon, getXPath, handleNodeSelection, handleNodeSelection, hasAncestor, hasAnnotation, hasAttributeXh, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, hasSiblingNodes, height, incVal, incVal, initStatics, inOrderPrint, insertAfter, insertAfter, insertAfter, insertBefore, insertBefore, insertBefore, insertFirstChild, isAttributeHandler, isExternal, isInternal, isLeaf, isRootNode, isUniqueSibling, isUniqueSiblingRoleName, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, processReceivedSyncMessage, processSystemMessageQ, reconfigure, registerMessageForwardee, remove, removeAttributeNodeXh, removeAttributeXh, removeChild, replaceNode, searchForReferencingNodes, searchForReferencingNodesRecurse, sendMessage, sendMessage, sendMessage, sendSyncMessage, sendSyncMessage, sendSyncMessage, sendSystemMessage, sendSystemMessage, setActionList, setAnnotation, setApp, setAttributeNodeXh, setAttributeVal, setAttributeXh, setFirstChild, setId, setName, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setRoleName, setUid, setUri, setVal_boolean, setVal_byte, setVal_char, setVal_double, setVal_float, setVal_int, setVal_long, setVal_Object, setVal_short, setVal_String, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setXhc, showAnnotation, swapNode, toXml, toXmlAttribute, toXmlAttributes, toXmlText, treeSize, visit
getClass, hashCode, notify, notifyAll, wait, wait, wait
act, actNr, appendChild, appendChild, appendChild, appendsOwnChildren, bindPorts, cleanup, configure, configure, consoleLog, decVal, decVal, depth, doAction, findFirstChildWithXhClass, findFirstChildWithXhClass, forwardMessage, forwardSyncMessage, getActionList, getAllPorts, getAnnotation, getApp, getAttributeNodeXh, getAttributeXh, getChildNodes, getClassNode, getClassNode, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumLevels, getNumSiblings, getParentNode, getPort, getPort, getPreviousSibling, getRoleName, getRootNode, getSelfAndSiblings, getSelfAndSiblingsIndex, getService, getSiblings, getUid, getUri, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXholon2Xml, getXhType, getXml2Xholon, handleNodeSelection, handleNodeSelection, hasAncestor, hasAnnotation, hasAttributeXh, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, hasSiblingNodes, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertAfter, insertAfter, insertBefore, insertBefore, insertBefore, insertFirstChild, isActiveObject, isAttributeHandler, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, isUniqueSibling, isUniqueSiblingRoleName, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, processReceivedSyncMessage, processSystemMessageQ, reconfigure, registerMessageForwardee, remove, removeAttributeNodeXh, removeAttributeXh, removeChild, replaceNode, searchForReferencingNodes, sendMessage, sendMessage, sendMessage, sendSyncMessage, sendSyncMessage, sendSyncMessage, sendSystemMessage, sendSystemMessage, setActionList, setAnnotation, setApp, setAttributeNodeXh, setAttributeVal, setAttributeXh, setFirstChild, setId, setName, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPort, setPort, setPorts, setRoleName, setUid, setUri, setVal_boolean, setVal_byte, setVal_char, setVal_double, setVal_float, setVal_int, setVal_long, setVal_Object, setVal_short, setVal_String, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setXhc, showAnnotation, swapNode, terminate, toXml, toXmlAttribute, toXmlAttributes, toXmlText, treeSize, visit
public int color
public double heading
public boolean isHidden
public int penMode
public double xcor
public double ycor
public void back(double distance)
ITurtle
public void bk(double distance)
ITurtle
public void beep()
ITurtle
public boolean canMove(double distance)
ITurtle
public void die()
ITurtle
public double distance(IXholon turtleOrPatch)
ITurtle
public double distancexy(double x, double y)
ITurtle
distancexy
in interface ITurtle
x
- A global x coordinate.y
- A global y coordinate.public double downhill()
ITurtle
public double downhill4()
ITurtle
public double dx()
ITurtle
public double dy()
ITurtle
public void face(IXholon turtleOrPatch)
ITurtle
public void facexy(double x, double y)
ITurtle
public void forward(double distance)
ITurtle
public void fd(double distance)
ITurtle
public void hatch(int numTurtles, int commandId)
ITurtle
public void hideTurtle()
ITurtle
hideTurtle
in interface ITurtle
public void ht()
ITurtle
public void home()
ITurtle
public IAgentSet inCone(double distance, double angle)
ITurtle
public IAgentSet inRadius(int radius)
ITurtle
public IAgentSet inRadius(int radius, int filterId)
ITurtle
public void jump(double distance)
ITurtle
public void jump(IPatch aPatch)
ITurtle
public void jump(ITurtle aTurtle)
ITurtle
public void left(double angle)
ITurtle
public void lt(double angle)
ITurtle
public IAgentSet neighbors()
ITurtle
public IAgentSet neighbors4()
ITurtle
neighbors4
in interface ITurtle
public IAgentSet otherTurtlesHere()
ITurtle
otherTurtlesHere
in interface ITurtle
public IPatch patchAhead(double distance)
ITurtle
patchAhead
in interface ITurtle
distance
- A distance measured in units.public IPatch patchAt(int dx, int dy)
ITurtle
public IPatch patchAtHeadingAndDistance(double heading, double distance)
ITurtle
patchAtHeadingAndDistance
in interface ITurtle
heading
- An absolute angle measured in degrees.distance
- A distance measured in units.public IPatch patchHere()
ITurtle
public IPatch patchLeftAndAhead(double distance, double angle)
ITurtle
patchLeftAndAhead
in interface ITurtle
distance
- A distance measured in units.angle
- An angle measured in degrees.public IPatch patchRightAndAhead(double distance, double angle)
ITurtle
patchRightAndAhead
in interface ITurtle
distance
- A distance measured in units.angle
- An angle measured in degrees.public void penDown()
ITurtle
public void pd()
ITurtle
public void penErase()
ITurtle
public void pe()
ITurtle
public void penUp()
ITurtle
public void pu()
ITurtle
public void right(double angle)
ITurtle
public void rt(double angle)
ITurtle
public void setxy(double x, double y)
ITurtle
public void showTurtle()
ITurtle
showTurtle
in interface ITurtle
public void st()
ITurtle
public void stamp()
ITurtle
public void stampErase()
ITurtle
stampErase
in interface ITurtle
public double towards(IXholon turtleOrPatch)
ITurtle
public double towardsxy(double x, double y)
ITurtle
public IAgentSet turtlesAt(int dx, int dy)
ITurtle
public IAgentSet turtlesHere()
ITurtle
turtlesHere
in interface ITurtle
public IAgentSet turtlesOn()
ITurtle
public double uphill()
ITurtle
public double uphill4()
ITurtle
public IAgentSet with(IAgentSet asIn, int filterId)
ITurtle
public int getBreed()
ITurtle
public void setBreed(int breed)
ITurtle
public int getColor()
ITurtle
public void setColor(int color)
ITurtle
public double getHeading()
ITurtle
getHeading
in interface ITurtle
public void setHeading(double heading)
ITurtle
setHeading
in interface ITurtle
heading
- An absolute angle measured in degrees.public boolean getIsHidden()
ITurtle
getIsHidden
in interface ITurtle
public void setIsHidden(boolean isHidden)
ITurtle
setIsHidden
in interface ITurtle
isHidden
- hidden (true) or visible (false)public java.lang.String getLabel()
ITurtle
public void setLabel(java.lang.String label)
ITurtle
public int getPenMode()
ITurtle
getPenMode
in interface ITurtle
public void setPenMode(int penMode)
ITurtle
setPenMode
in interface ITurtle
penMode
- A pen mode, one of PENMODE_UP, PENMODE_DOWN, or PENMODE_ERASE.public int getWho()
ITurtle
public void setWho(int who)
ITurtle
public double getXcor()
ITurtle
public void setXcor(double xcor)
ITurtle
public double getYcor()
ITurtle
public void setYcor(double ycor)
ITurtle
public int getPcolor()
ITurtle
public void setPcolor(int pcolor)
ITurtle
public java.lang.String getPlabel()
ITurtle
public void setPlabel(java.lang.String plabel)
ITurtle
public int getPxcor()
ITurtle
public void setPxcor(int pxcor)
ITurtle
public int getPycor()
ITurtle
public void setPycor(int pycor)
ITurtle
public int getMaxPxcor()
ITurtle
getMaxPxcor
in interface ITurtle
public int getMaxPycor()
ITurtle
getMaxPycor
in interface ITurtle
public int getMinPxcor()
ITurtle
getMinPxcor
in interface ITurtle
public int getMinPycor()
ITurtle
getMinPycor
in interface ITurtle
public int getWorldWidth()
ITurtle
getWorldWidth
in interface ITurtle
public int getWorldHeight()
ITurtle
getWorldHeight
in interface ITurtle
public boolean hasAlreadyMoved()
ITurtle
hasAlreadyMoved
in interface ITurtle
public void initWhenMoved(int when)
ITurtle
initWhenMoved
in interface ITurtle
when
- A time step, normally WHENMOVED_INIT (-1).public void aggregate(double amount)
ITurtle
public IXholon lineBresenham(int x0, int y0, int x1, int y1, int colr)
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.http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html
public java.lang.String toString()
XholonWithPorts
toString
in class XholonWithPorts