|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.primordion.xholon.base.Xholon org.primordion.xholon.base.XholonWithPorts org.primordion.xholon.base.Turtle
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.
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 java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int color
public double heading
public boolean isHidden
public int penMode
public double xcor
public double ycor
Constructor Detail |
public Turtle()
Method Detail |
public void back(double distance)
ITurtle
back
in interface ITurtle
distance
- A distance measured in units.public void bk(double distance)
ITurtle
bk
in interface ITurtle
distance
- A distance measured in units.public void beep()
ITurtle
beep
in interface ITurtle
public boolean canMove(double distance)
ITurtle
canMove
in interface ITurtle
distance
- A distance measured in units.
public void die()
ITurtle
die
in interface ITurtle
public double distance(IXholon turtleOrPatch)
ITurtle
distance
in interface ITurtle
turtleOrPatch
- A turtle or patch object.
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
downhill
in interface ITurtle
public double downhill4()
ITurtle
downhill4
in interface ITurtle
public double dx()
ITurtle
dx
in interface ITurtle
public double dy()
ITurtle
dy
in interface ITurtle
public void face(IXholon turtleOrPatch)
ITurtle
face
in interface ITurtle
turtleOrPatch
- A turtle or patch object.public void facexy(double x, double y)
ITurtle
facexy
in interface ITurtle
x
- A global x coordinate.y
- A global y coordinate.public void forward(double distance)
ITurtle
forward
in interface ITurtle
distance
- A distance measured in units.public void fd(double distance)
ITurtle
fd
in interface ITurtle
distance
- A distance measured in units.public void hatch(int numTurtles, int commandId)
ITurtle
hatch
in interface ITurtle
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.public void hideTurtle()
ITurtle
hideTurtle
in interface ITurtle
public void ht()
ITurtle
ht
in interface ITurtle
public void home()
ITurtle
home
in interface ITurtle
public java.util.Vector inCone(double distance, double angle)
ITurtle
inCone
in interface ITurtle
distance
- A distance measured in units.angle
- An angle measured in degrees.
public java.util.Vector inRadius(int radius)
ITurtle
inRadius
in interface ITurtle
radius
- Distance from the current patch. The current patch is a radius of 0 from itself.
public java.util.Vector inRadius(int radius, int filterId)
ITurtle
inRadius
in interface ITurtle
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.
public void jump(double distance)
ITurtle
jump
in interface ITurtle
distance
- A distance measured in units.public void jump(IPatch aPatch)
ITurtle
jump
in interface ITurtle
aPatch
- A patch.public void jump(ITurtle aTurtle)
ITurtle
jump
in interface ITurtle
aTurtle
- A turtle.public void left(double angle)
ITurtle
left
in interface ITurtle
angle
- An angle measured in degrees.public void lt(double angle)
ITurtle
lt
in interface ITurtle
angle
- A relative angle measured in degrees.public java.util.Vector neighbors()
ITurtle
neighbors
in interface ITurtle
public java.util.Vector neighbors4()
ITurtle
neighbors4
in interface ITurtle
public java.util.Vector 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
patchAt
in interface ITurtle
dx
- A relative distance in the x direction, in patches.dy
- A relative distance in the y direction, in patches.
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
patchHere
in interface 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
penDown
in interface ITurtle
public void pd()
ITurtle
pd
in interface ITurtle
public void penErase()
ITurtle
penErase
in interface ITurtle
public void pe()
ITurtle
pe
in interface ITurtle
public void penUp()
ITurtle
penUp
in interface ITurtle
public void pu()
ITurtle
pu
in interface ITurtle
public void right(double angle)
ITurtle
right
in interface ITurtle
angle
- An angle measured in degrees.public void rt(double angle)
ITurtle
rt
in interface ITurtle
angle
- A relative angle measured in degrees.public void setxy(double x, double y)
ITurtle
setxy
in interface ITurtle
x
- New value for the turtle's x coordinate.y
- New value for the turtle's y coordinate.public void showTurtle()
ITurtle
showTurtle
in interface ITurtle
public void st()
ITurtle
st
in interface ITurtle
public void stamp()
ITurtle
stamp
in interface ITurtle
public void stampErase()
ITurtle
stampErase
in interface ITurtle
public double towards(IXholon turtleOrPatch)
ITurtle
towards
in interface ITurtle
turtleOrPatch
- A turtle or patch object.
public double towardsxy(double x, double y)
ITurtle
towardsxy
in interface ITurtle
x
- A global x coordinate.y
- A global y coordinate.
public java.util.Vector turtlesAt(int dx, int dy)
ITurtle
turtlesAt
in interface ITurtle
dx
- A relative distance in the x direction, in patches.dy
- A relative distance in the y direction, in patches.
public java.util.Vector turtlesHere()
ITurtle
turtlesHere
in interface ITurtle
public java.util.Vector turtlesOn()
ITurtle
turtlesOn
in interface ITurtle
public double uphill()
ITurtle
uphill
in interface ITurtle
public double uphill4()
ITurtle
uphill4
in interface ITurtle
public java.util.Vector with(java.util.Vector vIn, int filterId)
ITurtle
with
in interface ITurtle
vIn
- A collection of ITurtle instances.
public int getBreed()
ITurtle
getBreed
in interface ITurtle
public void setBreed(int breed)
ITurtle
setBreed
in interface ITurtle
breed
- A breed id.public int getColor()
ITurtle
getColor
in interface ITurtle
public void setColor(int color)
ITurtle
setColor
in interface ITurtle
color
- A color value, as defined in ITurtlePatchColor.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
getLabel
in interface ITurtle
public void setLabel(java.lang.String label)
ITurtle
setLabel
in interface ITurtle
label
- 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
getWho
in interface ITurtle
public void setWho(int who)
ITurtle
setWho
in interface ITurtle
who
- A who id.public double getXcor()
ITurtle
getXcor
in interface ITurtle
public void setXcor(double xcor)
ITurtle
setXcor
in interface ITurtle
xcor
- An xcor value.public double getYcor()
ITurtle
getYcor
in interface ITurtle
public void setYcor(double ycor)
ITurtle
setYcor
in interface ITurtle
ycor
- An ycor value.public int getPcolor()
ITurtle
getPcolor
in interface ITurtle
public void setPcolor(int pcolor)
ITurtle
setPcolor
in interface ITurtle
pcolor
- A pcolor value, as defined in ITurtlePatchColor.public java.lang.String getPlabel()
ITurtle
getPlabel
in interface ITurtle
public void setPlabel(java.lang.String plabel)
ITurtle
setPlabel
in interface ITurtle
public int getPxcor()
ITurtle
getPxcor
in interface ITurtle
public void setPxcor(int pxcor)
ITurtle
setPxcor
in interface ITurtle
public int getPycor()
ITurtle
getPycor
in interface ITurtle
public void setPycor(int pycor)
ITurtle
setPycor
in interface 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
aggregate
in interface ITurtle
amount
- The amount to increment or decrement the current population count.
The amount can be a positive (increment) or negative (decrement) number.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()
toString
in class Xholon
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |