|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmadkit.kernel.AbstractAgent
turtlekit.kernel.Turtle
public class Turtle
The Turtle class implements the Turtle commands which are used to move set heading...
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 java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TURTLE_DEFAULT_ROLE
public static final int East
public static final int NorthEast
public static final int North
public static final int NorthWest
public static final int West
public static final int SouthWest
public static final int South
public static final int SouthEast
Constructor Detail |
---|
public Turtle()
public Turtle(java.lang.String initMethod)
Method Detail |
---|
public final java.lang.String defaultAction()
public void activate()
activate
in class AbstractAgent
public void end()
end
in class AbstractAgent
public void setup()
public final void die()
public java.lang.String toString()
toString
in class AbstractAgent
public java.lang.String getSimulationGroup()
public final void playRole(java.lang.String role)
public final boolean isPlayingRole(java.lang.String role)
public final void giveUpRole(java.lang.String role)
public final double getHeading()
public final void setHeading(double direction)
public final void setColor(java.awt.Color c)
public final java.awt.Color getColor()
public final void setHidden(boolean b)
public final boolean getHidden()
public final void setPatchColor(java.awt.Color c)
public final java.awt.Color getPatchColor()
public final java.awt.Color getPatchColorAt(int a, int b)
public final void setPatchColorAt(java.awt.Color c, int a, int b)
public final void fd(int nb)
public final void bk(int nb)
public final void moveTo(double a, double b)
public final void moveTo(int a, int b)
public final void home()
public final void setX(double a)
public final void setY(double b)
public final void setXY(double a, double b)
public final double distanceNowrap(double a, double b)
a
- the ab
- the b
public final double distance(double a, double b)
a
- the ab
- the b
public final double towardsNowrap(double a, double b)
public final double towards(double a, double b)
public final void randomHeading()
public final int createTurtle(Turtle t)
public final int xcor()
public final int ycor()
public final double realX()
public final double realY()
public final Turtle getTurtleWithID(int id)
public final int dx()
public final int dy()
public final void turnRight(double a)
public final void turnLeft(double a)
public final Turtle[] turtlesHere()
public final Turtle[] turtlesAt(int a, int b)
public final int countTurtlesHere()
public final int countTurtlesAt(int a, int b)
public final int mySelf()
public final int getWorldWidth()
public final int getWorldHeight()
public final double getPatchVariable(java.lang.String variableName)
public final double getPatchVariableAt(java.lang.String variableName, int a, int b)
public final void incrementPatchVariable(java.lang.String variableName, double value)
public final void incrementPatchVariableAt(java.lang.String variableName, double value, int a, int b)
public final java.lang.Object getMark(java.lang.String variableName)
public final java.lang.Object getMarkAt(java.lang.String variableName, int a, int b)
public final void dropMark(java.lang.String markName, java.lang.Object theMark)
markName:
- mark nametheMark:
- mark itself, can be any java objectpublic final void dropMarkAt(java.lang.String markName, java.lang.Object theMark, int a, int b)
public final boolean isMarkPresent(java.lang.String markName)
public final boolean isMarkPresentAt(java.lang.String markName, int a, int b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |