java.lang.Objectjava.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()
Turtleline-thickness
lineThickness in interface Turtle
public Patch getPatchAtOffsets(double dx,
double dy)
throws AgentException
getPatchAtOffsets in class AgentAgentException
public void jump(double distance)
throws AgentException
Turtlejump were used
jump in interface Turtledistance - this amount to jump
AgentException
public Patch getPatchAtHeadingAndDistance(double delta,
double distance)
throws AgentException
AgentExceptionpublic Patch getPatchHere()
Turtle
getPatchHere in interface Turtlepublic Object getVariable(int vn)
Agent
getVariable in interface AgentgetVariable in class Agentvn - the index into the agent variable array
public void setVariable(int vn,
Object value)
throws AgentException
Agent
setVariable in interface AgentsetVariable in class Agentvn - 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 Agentpublic Object getTurtleOrLinkVariable(String varName)
getTurtleOrLinkVariable in class Agentpublic Object getTurtleVariable(int vn)
getTurtleVariable in class Agentpublic double getTurtleVariableDouble(int vn)
public Object getLinkBreedVariable(String name)
throws AgentException
getLinkBreedVariable in class AgentAgentException
public Object getBreedVariable(String name)
throws AgentException
getBreedVariable in class AgentAgentExceptionpublic boolean ownsVariable(String name)
public Object getVariable(String name)
throws AgentException
AgentException
public Object getLinkVariable(int vn)
throws AgentException
getLinkVariable in class AgentAgentExceptionpublic Object getPatchVariable(int vn)
getPatchVariable in class Agent
public void setObserverVariable(int vn,
Object value)
throws AgentException,
LogoException
setObserverVariable in class AgentAgentException
LogoException
public void setTurtleOrLinkVariable(String varName,
Object value)
throws AgentException
setTurtleOrLinkVariable in class AgentAgentException
public void setTurtleVariable(int vn,
double value)
throws AgentException
setTurtleVariable in class AgentAgentException
public void setTurtleVariable(int vn,
Object value)
throws AgentException
setTurtleVariable in class AgentAgentException
public void setBreedVariable(String name,
Object value)
throws AgentException
setBreedVariable in class AgentAgentException
public void setPatchVariable(int vn,
Object value)
throws AgentException
setPatchVariable in class AgentAgentException
public void setPatchVariable(int vn,
double value)
throws AgentException
setPatchVariable in class AgentAgentException
public void setLinkVariable(int vn,
Object value)
throws AgentException
setLinkVariable in class AgentAgentException
public void setLinkVariable(int vn,
double value)
throws AgentException
setLinkVariable in class AgentAgentException
public void setLinkBreedVariable(String name,
Object value)
throws AgentException
setLinkBreedVariable in class AgentAgentExceptionpublic Object color()
Turtlecolor variable
color in interface Turtlepublic void colorDouble(Double boxedColor)
public void colorDoubleUnchecked(Double boxedColor)
public void color(LogoList rgb,
int varIndex)
throws AgentException
AgentExceptionpublic void turnRight(double delta)
public double heading()
Turtleheading variable
heading in interface Turtlepublic void heading(double heading)
Turtleheading variable
heading in interface Turtleheading - the new heading
public 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
AgentExceptionpublic double xcor()
Turtlexcor variable
xcor in interface Turtle
public void xcor(double xcor)
throws AgentException
AgentException
public void xcor(Double xcor)
throws AgentException
AgentExceptionpublic double ycor()
Turtleycor 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
AgentExceptionpublic 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 Agentpublic void shape(String shape)
public Object label()
public boolean hasLabel()
Turtlelabel variable has a non-empty string value
hasLabel in interface Turtlepublic String labelString()
Turtlelabel variable
labelString in interface Turtlepublic void label(Object label)
public Object labelColor()
Turtlelabel-color variable
labelColor in interface Turtlepublic void labelColor(double labelColor)
public void labelColor(LogoList rgb,
int valueIndex)
throws AgentException
AgentExceptionpublic AgentSet getBreed()
Turtle
getBreed in interface Turtlepublic int getBreedIndex()
Turtle
getBreedIndex in interface Turtlepublic void setBreed(AgentSet breed)
public Shape cachedShape()
cachedShape in interface Turtlepublic void cachedShape(Shape newShape)
cachedShape in interface Turtlepublic boolean hidden()
Turtlehidden? variable
hidden in interface Turtlepublic void hidden(boolean hidden)
public double size()
Agent
size in interface Agentpublic 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 Objectpublic String classDisplayName()
Agent
classDisplayName in interface AgentclassDisplayName in class Agentpublic Class<Turtle> getAgentClass()
getAgentClass in class Agentpublic int getAgentBit()
getAgentBit in class Agent