public class Patch extends Object
Constructor and Description |
---|
Patch() |
Modifier and Type | Method and Description |
---|---|
int |
countTurtles() |
void |
dropMark(String markName,
Object value)
Drop a mark on the patch
|
void |
dropPheromone(String name,
float quantity,
Float... parameters) |
Color |
getColor() |
Object |
getMark(String markName)
get a mark deposed on the patch
|
Turtle |
getNearestTurtle(int inRadius,
boolean includeThisPatch)
Gets the nearest turtle of type T in the vicinity of the patch.
|
<T extends Turtle> |
getNearestTurtle(int inRadius,
boolean includeThisPatch,
Class<T> turtleType)
Gets the nearest turtle of type T in the vicinity of the patch.
|
List<Patch> |
getNeighbors(int inRadius,
boolean includeThisPatch) |
List<Turtle> |
getTurtles() |
<T extends Turtle> |
getTurtles(Class<T> turtleType)
Get all the turtles on this patch
according to their type.
|
List<Turtle> |
getTurtles(int inRadius,
boolean includeThisPatch) |
<T extends Turtle> |
getTurtles(int inRadius,
boolean includeThisPatch,
Class<T> turtleType) |
List<Turtle> |
getTurtlesWithRole(int inRadius,
boolean includeThisPatch,
String role) |
<T extends Turtle> |
getTurtlesWithRole(int inRadius,
boolean includeThisPatch,
String role,
Class<T> turtleType) |
<T extends Turtle> |
getTurtlesWithRole(String role)
Get all the turtles which are on this patch
and having this role.
|
<T extends Turtle> |
getTurtlesWithRole(String role,
Class<T> turtleType)
Get all the turtles on this patch
according to their type and role.
|
boolean |
isEmpty() |
boolean |
isMarkPresent(String markName)
tests if the corresponding mark is present on the patch (true or false)
|
void |
setColor(Color c) |
void |
setCoordinates(int x,
int y) |
void |
setEnvironment(TKEnvironment environment) |
String |
toString() |
protected void |
update() |
public void setCoordinates(int x, int y)
public void setEnvironment(TKEnvironment environment)
public boolean isEmpty()
true
if there is no turtlepublic final void dropMark(String markName, Object value)
markName
- mark namevalue
- mark itself, can be any java objectpublic final Object getMark(String markName)
null
if not presentpublic final boolean isMarkPresent(String markName)
public <T extends Turtle> List<T> getTurtles(int inRadius, boolean includeThisPatch, Class<T> turtleType)
public <T extends Turtle> List<T> getTurtlesWithRole(int inRadius, boolean includeThisPatch, String role, Class<T> turtleType)
public List<Turtle> getTurtlesWithRole(int inRadius, boolean includeThisPatch, String role)
public <T extends Turtle> T getNearestTurtle(int inRadius, boolean includeThisPatch, Class<T> turtleType)
inRadius
- the range of the searchincludeThisPatch
- for the searchturtleType
- the type of the turtle as a Class
null
if no such turtle is foundpublic Turtle getNearestTurtle(int inRadius, boolean includeThisPatch)
inRadius
- the range of the searchincludeThisPatch
- for the searchnull
if there is
no turtle aroundpublic <T extends Turtle> List<T> getTurtles(Class<T> turtleType)
turtleType
- public <T extends Turtle> List<T> getTurtlesWithRole(String role, Class<T> turtleType)
role
- turtleType
- public <T extends Turtle> List<T> getTurtlesWithRole(String role)
role
- public int countTurtles()
public Color getColor()
public void setColor(Color c)
protected void update()