|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmadkit.kernel.AbstractAgent
edu.turtlekit2.kernel.agents.Turtle
public class Turtle
The Turtle class implements the Turtle commands which are used to move set heading...
Field Summary | |
---|---|
double |
angle
|
double |
angleCos
|
double |
angleSin
|
Color |
color
|
static int |
East
default direction values: setHeading(East) ~ setHeading(0) |
boolean |
hidden
|
protected String |
initMethod
|
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) |
Patch |
position
|
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 String |
TURTLE_DEFAULT_ROLE
|
static int |
West
default direction values: setHeading(East) ~ setHeading(0) |
double |
x
|
double |
y
|
Constructor Summary | |
---|---|
Turtle()
the initMethod is the first action (after setup) that the turtle will do |
|
Turtle(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 |
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(String markName,
Object theMark)
Drop a mark on the patch |
void |
dropMarkAt(String markName,
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 |
emit(String variableName,
double value)
set the value of the corresponding patch variable |
void |
end()
Madkit kernel usage : you must include super.end() when overriding |
void |
fd(int nb)
turtle move forward |
XMLAttributes |
getAttributes()
|
Color |
getColor()
|
int |
getCurrentBehaviorCount()
When the turtle switches its behavior the value of this counter is 0 |
double |
getDirectionOfMax(String patchVariableName)
Returns the heading toward the patch which has the highest value for patchVariable
in the immediate vicinity of the turtle |
double |
getDirectionOfMaxInMyDirection(String patchVariableName)
|
double |
getDirectionOfMin(String patchVariableName)
Returns the heading toward the patch which has the lowest value for patchVariable
in the immediate vicinity of the turtle |
double |
getDirectionOfMinInMyDirection(String patchVariableName)
|
double |
getHeading()
return the current heading of the turtle |
double |
getHeadingToMaxOf(String patchVariable,
int inRadius,
boolean wrap)
Returns the heading toward the patch which has the highest value for patchVariable
considering a radius in the vicinity of the agent. |
boolean |
getHidden()
|
Object |
getMark(String variableName)
get a mark deposed on the patch |
Object |
getMarkAt(String variableName,
int a,
int b)
|
Patch |
getPatchAt(int x,
int y)
|
Color |
getPatchColor()
|
Color |
getPatchColorAt(int a,
int b)
get the color of the patch situated at (a,b) units away |
Patch |
getPatchWithMaxOf(String patchVariable,
int inRadius)
Returns the patch which has the highest value for patchVariable
considering a radius in the vicinity of the agent. |
double[] |
getPerceptPatchVariable(String patchVariableName)
Returns an array of patchVariable quantity from the Turtle neighbors patches: - index * 180 gives the orientation of each neighbor - 8 is the patch where the turtle is. |
String |
getSimulationGroup()
get the MadKit group of the simulation |
ArrayList<Turtle> |
getTurtlesListWithRole(String role)
|
Turtle[] |
getTurtlesWithRole(String role)
|
Turtle |
getTurtleWithID(int id)
return the Turtle with the specified ID, null if not alive |
int |
getWorldHeight()
|
int |
getWorldWidth()
|
void |
giveUpRole(String role)
the turtle will no longer play the specified role |
void |
home()
teleport the turtle to the center patch |
void |
incrementBehaviorCount()
|
void |
incrementPatchVariableAt(String variableName,
double value,
int a,
int b)
|
void |
initialisation(int a,
int b,
TurtleEnvironment w,
int t,
Patch pos)
|
boolean |
isMarkPresent(String markName)
test if the corresponding mark is present on the patch (true or false) |
boolean |
isMarkPresentAt(String markName,
int a,
int b)
test if the corresponding mark is present on the patch situated at (a,b) units away |
boolean |
isPlayingRole(String role)
|
void |
moveTo(double a,
double b)
teleport the turtle to patch (a,b). |
void |
moveTo(int a,
int b)
teleport the turtle to patch (a,b). |
int |
mySelf()
return the turtle ID |
Patch |
nextPatch()
Get the next patch given the current heading |
void |
playRole(String role)
one way to identify a kind of turtle: give them a Role in the simulation. |
void |
randomHeading()
|
double |
realX()
|
double |
realY()
|
void |
setAttributes(XMLAttributes a)
|
void |
setColor(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 |
setNextAction(Method nextMethod)
|
void |
setPatchColor(Color c)
|
void |
setPatchColorAt(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)
|
double |
smell(String variableName)
return the value of the corresponding patch variable |
double |
smellAt(String variableName,
int a,
int b)
return the value of the patch situated at (a,b) units away |
double |
smellNextPatch(String variableName)
|
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()
return other turtles on the current patch |
void |
wiggle()
|
int |
xcor()
|
int |
ycor()
|
Methods inherited from class madkit.kernel.AbstractAgent |
---|
broadcastMessage, broadcastMessage, connectedWithCommunity, createGroup, createGroup, debug, disposeMyGUI, foundGroup, getAddress, getAgentInformation, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getAgentWithRole, getAvailableCommunities, getBean, getController, getCurrentKernelAddress, getDebug, getExistingGroups, getExistingGroups, getExistingRoles, getExistingRoles, getGroups, getGUIObject, getMessageBoxSize, getMyGroups, getMyGroups, getMyRoles, getMyRoles, getName, getRoles, hasGUI, hashCode, 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 |
---|
public static final 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
public double angle
public double x
public double y
public double angleCos
public double angleSin
public boolean hidden
protected String initMethod
public Color color
public Patch position
Constructor Detail |
---|
public Turtle()
public Turtle(String initMethod)
Method Detail |
---|
public int getCurrentBehaviorCount()
public final void setNextAction(Method nextMethod)
public String defaultAction()
public void initialisation(int a, int b, TurtleEnvironment w, int t, Patch pos)
public void activate()
activate
in class madkit.kernel.AbstractAgent
public void end()
end
in class madkit.kernel.AbstractAgent
public void setup()
public void die()
public void setAttributes(XMLAttributes a)
public XMLAttributes getAttributes()
public String toString()
toString
in class madkit.kernel.AbstractAgent
public String getSimulationGroup()
public void playRole(String role)
public boolean isPlayingRole(String role)
public void giveUpRole(String role)
public double getHeading()
public void setHeading(double direction)
public void setColor(Color c)
public Color getColor()
public void setHidden(boolean b)
public boolean getHidden()
public void setPatchColor(Color c)
public Color getPatchColor()
public Color getPatchColorAt(int a, int b)
public Patch getPatchAt(int x, int y)
public void setPatchColorAt(Color c, int a, int b)
public void fd(int nb)
public Patch nextPatch()
public void bk(int nb)
public void moveTo(double a, double b)
public void moveTo(int a, int b)
public void home()
public void setX(double a)
public void setY(double b)
public void setXY(double a, double b)
public double distanceNowrap(double a, double b)
public double distance(double a, double b)
a
- the ab
- the b
public double towardsNowrap(double a, double b)
public double towards(double a, double b)
public void randomHeading()
public int createTurtle(Turtle t)
public int xcor()
public int ycor()
public double realX()
public double realY()
public Turtle getTurtleWithID(int id)
public int dx()
public int dy()
public void turnRight(double a)
public void turnLeft(double a)
public Turtle[] turtlesHere()
public Turtle[] turtlesAt(int a, int b)
public int countTurtlesHere()
public int countTurtlesAt(int a, int b)
public int mySelf()
public int getWorldWidth()
public int getWorldHeight()
public double smell(String variableName)
public double smellNextPatch(String variableName)
public double smellAt(String variableName, int a, int b)
public void emit(String variableName, double value)
public void incrementPatchVariableAt(String variableName, double value, int a, int b)
public Object getMark(String variableName)
public Object getMarkAt(String variableName, int a, int b)
public void dropMark(String markName, Object theMark)
markName:
- mark nametheMark:
- mark itself, can be any java objectpublic void dropMarkAt(String markName, Object theMark, int a, int b)
public boolean isMarkPresent(String markName)
public boolean isMarkPresentAt(String markName, int a, int b)
public Turtle[] getTurtlesWithRole(String role)
public ArrayList<Turtle> getTurtlesListWithRole(String role)
public void wiggle()
public double[] getPerceptPatchVariable(String patchVariableName)
patchVariableName
-
public double getDirectionOfMax(String patchVariableName)
patchVariable
in the immediate vicinity of the turtle
patchVariableName
-
public double getDirectionOfMin(String patchVariableName)
patchVariable
in the immediate vicinity of the turtle
patchVariableName
-
public double getDirectionOfMaxInMyDirection(String patchVariableName)
public double getHeadingToMaxOf(String patchVariable, int inRadius, boolean wrap)
patchVariable
considering a radius in the vicinity of the agent.
patchVariable
- inRadius
- the highest distance from the agent which should be consideredwrap
- is the heading should be given considering the torus mode ?
public Patch getPatchWithMaxOf(String patchVariable, int inRadius)
patchVariable
considering a radius in the vicinity of the agent.
patchVariable
- inRadius
- the highest distance from the agent which should be considered
patchVariable
public double getDirectionOfMinInMyDirection(String patchVariableName)
public void incrementBehaviorCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |