Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## turtlekit.kernel
Class Turtle

    java.lang.Object
      madkit.kernel.AbstractAgent
          turtlekit.kernel.Turtle

All Implemented Interfaces:
  java.io.Serializable, ReferenceableAgent

Direct Known Subclasses:
  Animat, Animat, Animat, Ball, BlackHole, Creator, Gas, Mosquito, Ovni, Player, Predator, Prey, Star, Termite, Termite, Virus, Virus2, Walker

    public class Turtle

extends AbstractAgent
implements ReferenceableAgent

The Turtle class implements the Turtle commands which are used to move set heading...

Version:
  1.4 19/03/2008
Author:
  Fabien MICHEL
See Also:
  Serialized Form

Field Summary
`static int` | `East` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `North` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `NorthEast` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `NorthWest` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `South` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `SouthEast` default direction values: setHeading(East) ~ setHeading(0)
`static int` | `SouthWest` default direction values: setHeading(East) ~ setHeading(0)
`static java.lang.String` | `TURTLE_DEFAULT_ROLE`
`static int` | `West` default direction values: setHeading(East) ~ setHeading(0)

Constructor Summary
`Turtle()` the initMethod is the first action (after setup) that the turtle will do
`Turtle(java.lang.String initMethod)`

Method Summary
`void` | `activate()` Madkit kernel usage : you must include super.activate() when overriding
`void` | `bk(int nb)` turtle move backward
`int` | `countTurtlesAt(int a, int b)` return the number of turtles in the patch situated at (a,b) units away
`int` | `countTurtlesHere()`
`int` | `createTurtle(Turtle t)` create a turtle at the creator position (xcor,ycor) returns the ID of the new turtle
`java.lang.String` | `defaultAction()`
`void` | `die()`
`double` | `distance(double a, double b)` returns the distance from the patch (a,b).
`double` | `distanceNowrap(double a, double b)` return the "on screen distance" between the turtle and the patch of absolute coordinates (a,b).
`void` | `dropMark(java.lang.String markName, java.lang.Object theMark)` Drop a mark on the patch
`void` | `dropMarkAt(java.lang.String markName, java.lang.Object theMark, int a, int b)`
`int` | `dx()` return the x-increment if the turtle were to take one step forward in its current heading.
`int` | `dy()` return the y-increment if the turtle were to take one step forward in its current heading.
`void` | `end()` Madkit kernel usage : you should include super.end() when overriding
`void` | `fd(int nb)` turtle move forward
`java.awt.Color` | `getColor()`
`double` | `getHeading()` return the current heading of the turtle
`boolean` | `getHidden()`
`java.lang.Object` | `getMark(java.lang.String variableName)` get a mark deposed on the patch
`java.lang.Object` | `getMarkAt(java.lang.String variableName, int a, int b)`
`java.awt.Color` | `getPatchColor()`
`java.awt.Color` | `getPatchColorAt(int a, int b)` get the color of the patch situated at (a,b) units away
`double` | `getPatchVariable(java.lang.String variableName)` return the value of the corresponding patch variable
`double` | `getPatchVariableAt(java.lang.String variableName, int a, int b)` return the value of the patch situated at (a,b) units away
`java.lang.String` | `getSimulationGroup()` get the MadKit group of the simulation
`Turtle` | `getTurtleWithID(int id)` return the Turtle with the specified ID, null if not alive
`int` | `getWorldHeight()`
`int` | `getWorldWidth()`
`void` | `giveUpRole(java.lang.String role)` the turtle will no longer play the specified role
`void` | `home()` transfers the turtle to the center patch
`void` | `incrementPatchVariable(java.lang.String variableName, double value)` set the value of the corresponding patch variable
`void` | `incrementPatchVariableAt(java.lang.String variableName, double value, int a, int b)`
`boolean` | `isMarkPresent(java.lang.String markName)` test if the corresponding mark is present on the patch (true or false)
`boolean` | `isMarkPresentAt(java.lang.String markName, int a, int b)` test if the corresponding mark is present on the patch situated at (a,b) units away
`boolean` | `isPlayingRole(java.lang.String role)`
`void` | `moveTo(double a, double b)` transfers the turtle to patch (a,b).
`void` | `moveTo(int a, int b)`
`int` | `mySelf()` return the turtle ID
`void` | `playRole(java.lang.String role)` one way to identify a kind of turtle: give them a Role in the simulation.
`void` | `randomHeading()`
`double` | `realX()`
`double` | `realY()`
`void` | `setColor(java.awt.Color c)`
`void` | `setHeading(double direction)` set the turtle heading to the value of direction
`void` | `setHidden(boolean b)` if true, the turtle hides itself (no draw)
`void` | `setPatchColor(java.awt.Color c)`
`void` | `setPatchColorAt(java.awt.Color c, int a, int b)` set the color of the patch situated at (a,b) units away
`void` | `setup()`
`void` | `setX(double a)`
`void` | `setXY(double a, double b)`
`void` | `setY(double b)`
`java.lang.String` | `toString()`
`double` | `towards(double a, double b)` returns direction to the patch (a,b).
`double` | `towardsNowrap(double a, double b)`
`void` | `turnLeft(double a)`
`void` | `turnRight(double a)`
`Turtle[]` | `turtlesAt(int a, int b)` return turtles who are on the patch situated at (a,b) units away
`Turtle[]` | `turtlesHere()`
`int` | `xcor()`
`int` | `ycor()`

Methods inherited from class madkit.kernel.AbstractAgent
`broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, destroyGroup, disposeMyGUI, foundGroup, getAddress, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, hashCode, hideMyGUI, initGUI, isBelongingToGroup, isBelongingToGroup, isCommunity, isGroup, isGroup, isMemberOf, isMemberOf, isMessageBoxEmpty, isRole, isRole, joinGroup, killAgent, launchAgent, launchAgent, leaveGroup, leaveGroup, leaveRole, leaveRole, nextMessage, print, println, receiveMessage, redisplayMyGUI, requestRole, requestRole, requestRole, restoreAgent, sendMessage, sendMessage, sendMessage, setBean, setController, setDebug, setGUIObject, setName, setOutput, setOutputWriter, windowClosing`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### TURTLE_DEFAULT_ROLE

    public static final java.lang.String TURTLE_DEFAULT_ROLE

See Also:
  Constant Field Values

### East

    public static final int East

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### NorthEast

    public static final int NorthEast

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### North

    public static final int North

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### NorthWest

    public static final int NorthWest

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### West

    public static final int West

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### SouthWest

    public static final int SouthWest

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### South

    public static final int South

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

### SouthEast

    public static final int SouthEast

  default direction values: setHeading(East) ~ setHeading(0)

  See Also:
    Constant Field Values

Constructor Detail

### Turtle

    public Turtle()

  the initMethod is the first action (after setup) that the turtle will do

### Turtle

    public Turtle(java.lang.String initMethod)

Method Detail

### defaultAction

    public final java.lang.String defaultAction()

### activate

    public void activate()

  Madkit kernel usage : you must include super.activate() when overriding

  Overrides:
    `activate` in class `AbstractAgent`

### end

    public void end()

  Madkit kernel usage : you should include super.end() when overriding

  Overrides:
    `end` in class `AbstractAgent`

### setup

    public void setup()

### die

    public final void die()

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `AbstractAgent`

### getSimulationGroup

    public java.lang.String getSimulationGroup()

  get the MadKit group of the simulation

### playRole

    public final void playRole(java.lang.String role)

  one way to identify a kind of turtle: give them a Role in the simulation.

### isPlayingRole

    public final boolean isPlayingRole(java.lang.String role)

### giveUpRole

    public final void giveUpRole(java.lang.String role)

  the turtle will no longer play the specified role

### getHeading

    public final double getHeading()

  return the current heading of the turtle

### setHeading

    public final void setHeading(double direction)

  set the turtle heading to the value of direction

### setColor

    public final void setColor(java.awt.Color c)

### getColor

    public final java.awt.Color getColor()

### setHidden

    public final void setHidden(boolean b)

  if true, the turtle hides itself (no draw)

### getHidden

    public final boolean getHidden()

### setPatchColor

    public final void setPatchColor(java.awt.Color c)

### getPatchColor

    public final java.awt.Color getPatchColor()

### getPatchColorAt

    public final java.awt.Color getPatchColorAt(int a,
                                                int b)

  get the color of the patch situated at (a,b) units away

### setPatchColorAt

    public final void setPatchColorAt(java.awt.Color c,
                                      int a,
                                      int b)

  set the color of the patch situated at (a,b) units away

### fd

    public final void fd(int nb)

  turtle move forward

### bk

    public final void bk(int nb)

  turtle move backward

### moveTo

    public final void moveTo(double a,
                             double b)

  transfers the turtle to patch (a,b). Can be used as a jump primitive: MoveTo(xcor()+10,ycor())

### moveTo

    public final void moveTo(int a,
                             int b)

### home

    public final void home()

  transfers the turtle to the center patch

### setX

    public final void setX(double a)

### setY

    public final void setY(double b)

### setXY

    public final void setXY(double a,
                            double b)

### distanceNowrap

    public final double distanceNowrap(double a,
                                       double b)

  return the "on screen distance" between the turtle and the patch of absolute coordinates (a,b).

  Parameters:
    `a` - the a
    `b` - the b
  Returns:
    a distance using double

### distance

    public final double distance(double a,
                                 double b)

  returns the distance from the patch (a,b). The "wrapped distance", when wrap mode is on, (around the edges of the screen) if that distance is shorter than the "onscreen distance."

  Parameters:
    `a` - the a
    `b` - the b
  Returns:
    the distance using double

### towardsNowrap

    public final double towardsNowrap(double a,
                                      double b)

### towards

    public final double towards(double a,
                                double b)

  returns direction to the patch (a,b). If the "wrapped distance", when wrap mode is on, (around the edges of the screen) is shorter than the "onscreen distance," towards will report the direction of the wrapped path, otherwise it while will report the direction of the onscreen path

### randomHeading

    public final void randomHeading()

### createTurtle

    public final int createTurtle(Turtle t)

  create a turtle at the creator position (xcor,ycor) returns the ID of the new turtle

### xcor

    public final int xcor()

### ycor

    public final int ycor()

### realX

    public final double realX()

### realY

    public final double realY()

### getTurtleWithID

    public final Turtle getTurtleWithID(int id)

  return the Turtle with the specified ID, null if not alive

### dx

    public final int dx()

  return the x-increment if the turtle were to take one step forward in its current heading.

### dy

    public final int dy()

  return the y-increment if the turtle were to take one step forward in its current heading.

### turnRight

    public final void turnRight(double a)

### turnLeft

    public final void turnLeft(double a)

### turtlesHere

    public final Turtle[] turtlesHere()

  Returns:
    the other turtles on the current patch

### turtlesAt

    public final Turtle[] turtlesAt(int a,
                                    int b)

  return turtles who are on the patch situated at (a,b) units away

### countTurtlesHere

    public final int countTurtlesHere()

### countTurtlesAt

    public final int countTurtlesAt(int a,
                                    int b)

  return the number of turtles in the patch situated at (a,b) units away

### mySelf

    public final int mySelf()

  return the turtle ID

### getWorldWidth

    public final int getWorldWidth()

### getWorldHeight

    public final int getWorldHeight()

### getPatchVariable

    public final double getPatchVariable(java.lang.String variableName)

  return the value of the corresponding patch variable

### getPatchVariableAt

    public final double getPatchVariableAt(java.lang.String variableName,
                                           int a,
                                           int b)

  return the value of the patch situated at (a,b) units away

### incrementPatchVariable

    public final void incrementPatchVariable(java.lang.String variableName,
                                             double value)

  set the value of the corresponding patch variable

### incrementPatchVariableAt

    public final void incrementPatchVariableAt(java.lang.String variableName,
                                               double value,
                                               int a,
                                               int b)

### getMark

    public final java.lang.Object getMark(java.lang.String variableName)

  get a mark deposed on the patch

  Returns:
    the corresponding java object, null if not present

### getMarkAt

    public final java.lang.Object getMarkAt(java.lang.String variableName,
                                            int a,
                                            int b)

### dropMark

    public final void dropMark(java.lang.String markName,
                               java.lang.Object theMark)

  Drop a mark on the patch

  Parameters:
    `markName:` - mark name
    `theMark:` - mark itself, can be any java object

### dropMarkAt

    public final void dropMarkAt(java.lang.String markName,
                                 java.lang.Object theMark,
                                 int a,
                                 int b)

### isMarkPresent

    public final boolean isMarkPresent(java.lang.String markName)

  test if the corresponding mark is present on the patch (true or false)

### isMarkPresentAt

    public final boolean isMarkPresentAt(java.lang.String markName,
                                         int a,
                                         int b)

  test if the corresponding mark is present on the patch situated at (a,b) units away

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.