java.lang.Object java.util.Observable org.nlogo.agent.Agent org.nlogo.agent.Turtle
public class Turtle
Field Summary | |
---|---|
static int |
BIT
|
int |
LAST_PREDEFINED_VAR
|
int |
NUMBER_PREDEFINED_VARS
|
static String |
PEN_DOWN
|
static String |
PEN_ERASE
|
static String |
PEN_UP
|
static int |
VAR_COLOR
|
static int |
VAR_HEADING
|
static int |
VAR_LABEL
|
static int |
VAR_WHO
|
static int |
VAR_XCOR
|
static int |
VAR_YCOR
|
Fields inherited from class org.nlogo.agent.Agent |
---|
id, variables |
Constructor Summary | |
---|---|
Turtle(World world,
AgentSet breed,
Double xcor,
Double ycor)
|
Method Summary | |
---|---|
Shape |
cachedShape()
|
void |
cachedShape(Shape newShape)
|
String |
classDisplayName()
Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer) |
Object |
color()
Returns the value of the color variable |
void |
color(LogoList rgb,
int varIndex)
|
void |
colorDouble(Double boxedColor)
|
void |
colorDoubleUnchecked(Double boxedColor)
|
void |
die()
|
double |
dx()
|
double |
dy()
|
void |
face(Agent agent,
boolean wrap)
|
void |
face(double x,
double y,
boolean wrap)
|
int |
getAgentBit()
|
Class<Turtle> |
getAgentClass()
|
AgentSet |
getBreed()
Returns the breed AgentSet of this turtle, all turtles if the turtle is unbreeded |
int |
getBreedIndex()
Returns the index of this turtle's breed |
Object |
getBreedVariable(String name)
|
Object |
getLinkBreedVariable(String name)
|
Object |
getLinkVariable(int vn)
|
Object |
getObserverVariable(int vn)
|
Patch |
getPatchAtHeadingAndDistance(double delta,
double distance)
|
Patch |
getPatchAtOffsets(double dx,
double dy)
|
Patch |
getPatchHere()
Returns the patch that this turtle is on |
Object |
getPatchVariable(int vn)
|
Object |
getTurtleOrLinkVariable(String varName)
|
Object |
getTurtleVariable(int vn)
|
double |
getTurtleVariableDouble(int vn)
|
Object |
getVariable(int vn)
Returns the value of the variable in the given position of the agent variable array |
Object |
getVariable(String name)
|
boolean |
hasLabel()
Returns true if the label variable has a non-empty string value |
Turtle |
hatch()
|
double |
heading()
Returns the value of the heading variable |
void |
heading(double heading)
Sets the value of the heading variable |
void |
heading(Double heading)
|
void |
heading(double heading,
Set<Turtle> seenTurtles)
|
boolean |
hidden()
Returns the value of the hidden? |
void |
hidden(boolean hidden)
|
void |
home()
|
void |
jump(double distance)
Moves the turtle forward distance as if the command jump were used |
Object |
label()
|
void |
label(Object label)
|
Object |
labelColor()
Returns the value of the label-color variable |
void |
labelColor(double labelColor)
|
void |
labelColor(LogoList rgb,
int valueIndex)
|
String |
labelString()
Returns the value of the label variable |
double |
lineThickness()
Returns the line-thickness |
void |
moveTo(Agent otherAgent)
|
void |
moveToPatchCenter()
|
boolean |
ownsVariable(String name)
|
String |
penMode()
|
void |
penMode(String penMode)
|
double |
penSize()
|
void |
penSize(double penSize)
|
void |
setBreed(AgentSet breed)
This version of setBreed properly resets the global breed AgentSets Caller should ensure that the turtle isn't a link (links aren't allowed to change breed). |
void |
setBreedVariable(String name,
Object value)
|
void |
setLinkBreedVariable(String name,
Object value)
|
void |
setLinkVariable(int vn,
double value)
|
void |
setLinkVariable(int vn,
Object value)
|
void |
setObserverVariable(int vn,
Object value)
|
void |
setPatchVariable(int vn,
double value)
|
void |
setPatchVariable(int vn,
Object value)
|
void |
setTurtleOrLinkVariable(String varName,
Object value)
|
void |
setTurtleVariable(int vn,
double value)
|
void |
setTurtleVariable(int vn,
Object value)
|
void |
setVariable(int vn,
Object value)
Sets the variable in the position vn of the agent variable array to value |
String |
shape()
Returns the name of the current shape, empty string in the case of patches. |
void |
shape(String shape)
|
double |
shortestPathX(double x)
|
double |
shortestPathY(double y)
|
double |
size()
Returns the size of this agent |
void |
size(double size)
|
static double |
subtractHeadings(double h1,
double h2)
|
String |
toString()
|
void |
turnRight(double delta)
|
void |
xandycor(double xcor,
double ycor)
|
void |
xandycor(Double xcor,
Double ycor)
|
void |
xandycor(double xcor,
double ycor,
Set<Turtle> seenTurtles)
|
void |
xandycorHelper(double xcor,
double ycor)
|
double |
xcor()
Returns the value of the xcor variable |
void |
xcor(double xcor)
|
void |
xcor(Double xcor)
|
double |
ycor()
Returns the value of the ycor variable |
void |
ycor(double ycor)
|
void |
ycor(Double ycor)
|
Methods inherited from class org.nlogo.agent.Agent |
---|
compareTo, getVariableCount, id, variableConstraint, variableConstraint, world |
Methods inherited from class java.util.Observable |
---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.nlogo.api.Agent |
---|
id, world |
Field Detail |
---|
public static final int VAR_WHO
public static final int VAR_COLOR
public static final int VAR_HEADING
public static final int VAR_XCOR
public static final int VAR_YCOR
public static final int VAR_LABEL
public int LAST_PREDEFINED_VAR
public int NUMBER_PREDEFINED_VARS
public static final String PEN_UP
public static final String PEN_DOWN
public static final String PEN_ERASE
public static final int BIT
Constructor Detail |
---|
public Turtle(World world, AgentSet breed, Double xcor, Double ycor)
Method Detail |
---|
public Turtle hatch()
public void die()
public double lineThickness()
Turtle
line-thickness
lineThickness
in interface Turtle
public Patch getPatchAtOffsets(double dx, double dy) throws AgentException
getPatchAtOffsets
in class Agent
AgentException
public void jump(double distance) throws AgentException
Turtle
jump
were used
jump
in interface Turtle
distance
- this amount to jump
AgentException
public Patch getPatchAtHeadingAndDistance(double delta, double distance) throws AgentException
AgentException
public Patch getPatchHere()
Turtle
getPatchHere
in interface Turtle
public Object getVariable(int vn)
Agent
getVariable
in interface Agent
getVariable
in class Agent
vn
- the index into the agent variable arraypublic void setVariable(int vn, Object value) throws AgentException
Agent
setVariable
in interface Agent
setVariable
in class Agent
vn
- the index into the agent variable arrayvalue
- the new value for the variable
AgentException
- If value is the wrong type for the given variable or if you try to change variables that cannot be changedpublic Object getObserverVariable(int vn)
getObserverVariable
in class Agent
public Object getTurtleOrLinkVariable(String varName)
getTurtleOrLinkVariable
in class Agent
public Object getTurtleVariable(int vn)
getTurtleVariable
in class Agent
public double getTurtleVariableDouble(int vn)
public Object getLinkBreedVariable(String name) throws AgentException
getLinkBreedVariable
in class Agent
AgentException
public Object getBreedVariable(String name) throws AgentException
getBreedVariable
in class Agent
AgentException
public boolean ownsVariable(String name)
public Object getVariable(String name) throws AgentException
AgentException
public Object getLinkVariable(int vn) throws AgentException
getLinkVariable
in class Agent
AgentException
public Object getPatchVariable(int vn)
getPatchVariable
in class Agent
public void setObserverVariable(int vn, Object value) throws AgentException, LogoException
setObserverVariable
in class Agent
AgentException
LogoException
public void setTurtleOrLinkVariable(String varName, Object value) throws AgentException
setTurtleOrLinkVariable
in class Agent
AgentException
public void setTurtleVariable(int vn, double value) throws AgentException
setTurtleVariable
in class Agent
AgentException
public void setTurtleVariable(int vn, Object value) throws AgentException
setTurtleVariable
in class Agent
AgentException
public void setBreedVariable(String name, Object value) throws AgentException
setBreedVariable
in class Agent
AgentException
public void setPatchVariable(int vn, Object value) throws AgentException
setPatchVariable
in class Agent
AgentException
public void setPatchVariable(int vn, double value) throws AgentException
setPatchVariable
in class Agent
AgentException
public void setLinkVariable(int vn, Object value) throws AgentException
setLinkVariable
in class Agent
AgentException
public void setLinkVariable(int vn, double value) throws AgentException
setLinkVariable
in class Agent
AgentException
public void setLinkBreedVariable(String name, Object value) throws AgentException
setLinkBreedVariable
in class Agent
AgentException
public Object color()
Turtle
color
variable
color
in interface Turtle
public void colorDouble(Double boxedColor)
public void colorDoubleUnchecked(Double boxedColor)
public void color(LogoList rgb, int varIndex) throws AgentException
AgentException
public void turnRight(double delta)
public double heading()
Turtle
heading
variable
heading
in interface Turtle
public void heading(double heading)
Turtle
heading
variable
heading
in interface Turtle
heading
- the new headingpublic void heading(double heading, Set<Turtle> seenTurtles)
public void heading(Double heading)
public void moveTo(Agent otherAgent) throws AgentException
AgentException
public double shortestPathY(double y) throws AgentException
AgentException
public double shortestPathX(double x) throws AgentException
AgentException
public double xcor()
Turtle
xcor
variable
xcor
in interface Turtle
public void xcor(double xcor) throws AgentException
AgentException
public void xcor(Double xcor) throws AgentException
AgentException
public double ycor()
Turtle
ycor
variable
ycor
in interface Turtle
public void ycor(double ycor) throws AgentException
AgentException
public void ycor(Double ycor) throws AgentException
AgentException
public void xandycor(double xcor, double ycor) throws AgentException
AgentException
public void xandycor(double xcor, double ycor, Set<Turtle> seenTurtles) throws AgentException
AgentException
public void xandycorHelper(double xcor, double ycor) throws AgentException
AgentException
public void xandycor(Double xcor, Double ycor) throws AgentException
AgentException
public void moveToPatchCenter()
public void face(Agent agent, boolean wrap)
public void face(double x, double y, boolean wrap)
public static double subtractHeadings(double h1, double h2)
public void home()
public double dx()
public double dy()
public String shape()
Agent
shape
in interface Agent
public void shape(String shape)
public Object label()
public boolean hasLabel()
Turtle
label
variable has a non-empty string value
hasLabel
in interface Turtle
public String labelString()
Turtle
label
variable
labelString
in interface Turtle
public void label(Object label)
public Object labelColor()
Turtle
label-color
variable
labelColor
in interface Turtle
public void labelColor(double labelColor)
public void labelColor(LogoList rgb, int valueIndex) throws AgentException
AgentException
public AgentSet getBreed()
Turtle
getBreed
in interface Turtle
public int getBreedIndex()
Turtle
getBreedIndex
in interface Turtle
public void setBreed(AgentSet breed)
public Shape cachedShape()
cachedShape
in interface Turtle
public void cachedShape(Shape newShape)
cachedShape
in interface Turtle
public boolean hidden()
Turtle
hidden?
variable
hidden
in interface Turtle
public void hidden(boolean hidden)
public double size()
Agent
size
in interface Agent
public void size(double size)
public double penSize()
public void penSize(double penSize)
public String penMode()
public void penMode(String penMode)
public String toString()
toString
in class Object
public String classDisplayName()
Agent
classDisplayName
in interface Agent
classDisplayName
in class Agent
public Class<Turtle> getAgentClass()
getAgentClass
in class Agent
public int getAgentBit()
getAgentBit
in class Agent