org.nlogo.agent
Class Turtle

java.lang.Object
  extended by java.util.Observable
      extended by org.nlogo.agent.Agent
          extended by org.nlogo.agent.Turtle
All Implemented Interfaces:
Comparable, RenderableAgent, RenderableTurtle, Agent, Turtle
Direct Known Subclasses:
Turtle3D

public class Turtle
extends Agent
implements Turtle, RenderableTurtle


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()
           
 Object color()
           
 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 getAgentClass()
           
 AgentSet getBreed()
           
 int getBreedIndex()
           
 Object getBreedVariable(String name)
           
static List getImplicitVariables()
           
 Object getLinkBreedVariable(String name)
           
 Object getLinkVariable(int vn)
           
 double getLinkVariableDouble(int vn)
           
 Object getObserverVariable(int vn)
           
 Patch getPatchAtHeadingAndDistance(double delta, double distance)
           
 Patch getPatchAtOffsets(double dx, double dy)
           
 Patch getPatchHere()
           
 Object getPatchVariable(int vn)
           
 double getPatchVariableDouble(int vn)
           
 Object getTurtleOrLinkVariable(String varName)
           
 Object getTurtleVariable(int vn)
           
 double getTurtleVariableDouble(int vn)
           
 Object getVariable(int vn)
           
 Object getVariable(String name)
           
 boolean hasLabel()
           
 Turtle hatch()
           
 double heading()
           
 void heading(double heading)
           
 void heading(Double heading)
           
 void heading(double heading, HashSet seenTurtles)
           
 void headingHelper(double heading)
           
 boolean hidden()
           
 void hidden(boolean hidden)
           
 void home()
           
 Double id()
           
 boolean isDirectedLink()
           
static boolean isDoubleVariable(int vn)
           
static boolean isSpecialVariable(int vn)
           
 void jump(double distance)
           
 Object label()
           
 void label(Object label)
           
 Object labelColor()
           
 void labelColor(double labelColor)
           
 void labelColor(LogoList rgb, int valueIndex)
           
 String labelString()
           
 double lineThickness()
           
 double linkDestinationSize()
           
 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)
           
 String shape()
           
 void shape(String shape)
           
 double shortestPathX(double x)
           
 double shortestPathY(double y)
           
 double size()
           
 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, HashSet seenTurtles)
           
 void xandycorHelper(double xcor, double ycor)
           
 double xcor()
           
 void xcor(double xcor)
           
 void xcor(Double xcor)
           
 double ycor()
           
 void ycor(double ycor)
           
 void ycor(Double ycor)
           
 
Methods inherited from class org.nlogo.agent.Agent
compareTo, getVariableCount, 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
 

Field Detail

VAR_WHO

public static final int VAR_WHO
See Also:
Constant Field Values

VAR_COLOR

public static final int VAR_COLOR
See Also:
Constant Field Values

VAR_HEADING

public static final int VAR_HEADING
See Also:
Constant Field Values

VAR_XCOR

public static final int VAR_XCOR
See Also:
Constant Field Values

VAR_YCOR

public static final int VAR_YCOR
See Also:
Constant Field Values

VAR_LABEL

public static final int VAR_LABEL
See Also:
Constant Field Values

LAST_PREDEFINED_VAR

public int LAST_PREDEFINED_VAR

NUMBER_PREDEFINED_VARS

public int NUMBER_PREDEFINED_VARS

PEN_UP

public static final String PEN_UP
See Also:
Constant Field Values

PEN_DOWN

public static final String PEN_DOWN
See Also:
Constant Field Values

PEN_ERASE

public static final String PEN_ERASE
See Also:
Constant Field Values

BIT

public static final int BIT
See Also:
Constant Field Values
Constructor Detail

Turtle

public Turtle(World world,
              AgentSet breed,
              Double xcor,
              Double ycor)
Method Detail

id

public Double id()

hatch

public Turtle hatch()

die

public void die()

lineThickness

public double lineThickness()
Specified by:
lineThickness in interface RenderableAgent

getImplicitVariables

public static List getImplicitVariables()

isDoubleVariable

public static boolean isDoubleVariable(int vn)

isSpecialVariable

public static boolean isSpecialVariable(int vn)

getPatchAtOffsets

public Patch getPatchAtOffsets(double dx,
                               double dy)
                        throws AgentException
Specified by:
getPatchAtOffsets in class Agent
Throws:
AgentException

jump

public void jump(double distance)
          throws AgentException
Throws:
AgentException

getPatchAtHeadingAndDistance

public Patch getPatchAtHeadingAndDistance(double delta,
                                          double distance)
                                   throws AgentException
Throws:
AgentException

getPatchHere

public Patch getPatchHere()

getVariable

public Object getVariable(int vn)
Specified by:
getVariable in class Agent

setVariable

public void setVariable(int vn,
                        Object value)
                 throws AgentException
Specified by:
setVariable in class Agent
Throws:
AgentException

getObserverVariable

public Object getObserverVariable(int vn)
Specified by:
getObserverVariable in class Agent

getTurtleOrLinkVariable

public Object getTurtleOrLinkVariable(String varName)
                               throws AgentException
Specified by:
getTurtleOrLinkVariable in class Agent
Throws:
AgentException

getTurtleVariable

public Object getTurtleVariable(int vn)
Specified by:
getTurtleVariable in class Agent

getTurtleVariableDouble

public double getTurtleVariableDouble(int vn)
Specified by:
getTurtleVariableDouble in class Agent

getLinkBreedVariable

public Object getLinkBreedVariable(String name)
                            throws AgentException
Specified by:
getLinkBreedVariable in class Agent
Throws:
AgentException

getBreedVariable

public Object getBreedVariable(String name)
                        throws AgentException
Specified by:
getBreedVariable in class Agent
Throws:
AgentException

ownsVariable

public boolean ownsVariable(String name)

getVariable

public Object getVariable(String name)
                   throws AgentException
Throws:
AgentException

getLinkVariable

public Object getLinkVariable(int vn)
                       throws AgentException
Specified by:
getLinkVariable in class Agent
Throws:
AgentException

getLinkVariableDouble

public double getLinkVariableDouble(int vn)
                             throws AgentException
Specified by:
getLinkVariableDouble in class Agent
Throws:
AgentException

getPatchVariable

public Object getPatchVariable(int vn)
Specified by:
getPatchVariable in class Agent

getPatchVariableDouble

public double getPatchVariableDouble(int vn)
Specified by:
getPatchVariableDouble in class Agent

setObserverVariable

public void setObserverVariable(int vn,
                                Object value)
                         throws AgentException,
                                LogoException
Specified by:
setObserverVariable in class Agent
Throws:
AgentException
LogoException

setTurtleOrLinkVariable

public void setTurtleOrLinkVariable(String varName,
                                    Object value)
                             throws AgentException
Specified by:
setTurtleOrLinkVariable in class Agent
Throws:
AgentException

setTurtleVariable

public void setTurtleVariable(int vn,
                              double value)
                       throws AgentException
Specified by:
setTurtleVariable in class Agent
Throws:
AgentException

setTurtleVariable

public void setTurtleVariable(int vn,
                              Object value)
                       throws AgentException
Specified by:
setTurtleVariable in class Agent
Throws:
AgentException

setBreedVariable

public void setBreedVariable(String name,
                             Object value)
                      throws AgentException
Specified by:
setBreedVariable in class Agent
Throws:
AgentException

setPatchVariable

public void setPatchVariable(int vn,
                             Object value)
                      throws AgentException
Specified by:
setPatchVariable in class Agent
Throws:
AgentException

setPatchVariable

public void setPatchVariable(int vn,
                             double value)
                      throws AgentException
Specified by:
setPatchVariable in class Agent
Throws:
AgentException

setLinkVariable

public void setLinkVariable(int vn,
                            Object value)
                     throws AgentException
Specified by:
setLinkVariable in class Agent
Throws:
AgentException

setLinkVariable

public void setLinkVariable(int vn,
                            double value)
                     throws AgentException
Specified by:
setLinkVariable in class Agent
Throws:
AgentException

setLinkBreedVariable

public void setLinkBreedVariable(String name,
                                 Object value)
                          throws AgentException
Specified by:
setLinkBreedVariable in class Agent
Throws:
AgentException

color

public Object color()
Specified by:
color in interface RenderableAgent

colorDouble

public void colorDouble(Double boxedColor)

colorDoubleUnchecked

public void colorDoubleUnchecked(Double boxedColor)

color

public void color(LogoList rgb,
                  int varIndex)
           throws AgentException
Throws:
AgentException

turnRight

public void turnRight(double delta)

heading

public double heading()
Specified by:
heading in interface RenderableTurtle

heading

public void heading(double heading)

heading

public void heading(double heading,
                    HashSet seenTurtles)

headingHelper

public void headingHelper(double heading)

heading

public void heading(Double heading)

moveTo

public void moveTo(Agent otherAgent)
            throws AgentException
Throws:
AgentException

shortestPathY

public double shortestPathY(double y)
                     throws AgentException
Throws:
AgentException

shortestPathX

public double shortestPathX(double x)
                     throws AgentException
Throws:
AgentException

xcor

public double xcor()
Specified by:
xcor in interface RenderableTurtle

xcor

public void xcor(double xcor)
          throws AgentException
Throws:
AgentException

xcor

public void xcor(Double xcor)
          throws AgentException
Throws:
AgentException

ycor

public double ycor()
Specified by:
ycor in interface RenderableTurtle

ycor

public void ycor(double ycor)
          throws AgentException
Throws:
AgentException

ycor

public void ycor(Double ycor)
          throws AgentException
Throws:
AgentException

xandycor

public void xandycor(double xcor,
                     double ycor)
              throws AgentException
Throws:
AgentException

xandycor

public void xandycor(double xcor,
                     double ycor,
                     HashSet seenTurtles)
              throws AgentException
Throws:
AgentException

xandycorHelper

public void xandycorHelper(double xcor,
                           double ycor)
                    throws AgentException
Throws:
AgentException

xandycor

public void xandycor(Double xcor,
                     Double ycor)
              throws AgentException
Throws:
AgentException

moveToPatchCenter

public void moveToPatchCenter()

face

public void face(Agent agent,
                 boolean wrap)

face

public void face(double x,
                 double y,
                 boolean wrap)

subtractHeadings

public static double subtractHeadings(double h1,
                                      double h2)

home

public void home()

dx

public double dx()

dy

public double dy()

shape

public String shape()
Specified by:
shape in interface RenderableAgent

shape

public void shape(String shape)

label

public Object label()

hasLabel

public boolean hasLabel()
Specified by:
hasLabel in interface RenderableAgent

labelString

public String labelString()
Specified by:
labelString in interface RenderableAgent

label

public void label(Object label)

labelColor

public Object labelColor()
Specified by:
labelColor in interface RenderableAgent

labelColor

public void labelColor(double labelColor)

labelColor

public void labelColor(LogoList rgb,
                       int valueIndex)
                throws AgentException
Throws:
AgentException

getBreed

public AgentSet getBreed()

getBreedIndex

public int getBreedIndex()

setBreed

public 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).


cachedShape

public Shape cachedShape()
Specified by:
cachedShape in interface RenderableTurtle

cachedShape

public void cachedShape(Shape newShape)
Specified by:
cachedShape in interface RenderableTurtle

hidden

public boolean hidden()

hidden

public void hidden(boolean hidden)

size

public double size()
Specified by:
size in interface RenderableAgent

size

public void size(double size)

penSize

public double penSize()

penSize

public void penSize(double penSize)

penMode

public String penMode()

penMode

public void penMode(String penMode)

toString

public String toString()
Overrides:
toString in class Object

classDisplayName

public String classDisplayName()
Specified by:
classDisplayName in class Agent

getAgentClass

public Class getAgentClass()
Specified by:
getAgentClass in class Agent

getAgentBit

public int getAgentBit()
Specified by:
getAgentBit in class Agent

isDirectedLink

public boolean isDirectedLink()

linkDestinationSize

public double linkDestinationSize()
                           throws AgentException
Throws:
AgentException