You are not logged in.
Dear all,
I would like to access the turtles, in order to display some info about them in a separate panel. How can I access turtles ?
In TurtleActivator, there is a way, but this method is local and non-static. As the turtle set and the patch set are unique objects, is there a way to obtain static access to it ?
Thank you in advance for your help
Offline
Hi,
One way oif accessing the turtle is bu using a TurtleProbe probe within a Viewer or in a Observer. So, you can have access to all the turtles and do some treatment on their attributes. Here is a sample taken from src/edu/turtlekit2/demos/gas :
public void setup() {
...
allTurtles = new TurtleProbe(getSimulationGroup(),"turtle");
addProbe(allTurtles);
}
public void watch(){
int cpt = 0;
//computing how many turtles are on the right side of the wall
for (final Turtle t : allTurtles.getCurrentAgentsList()) {
if (t.xcor()>= ((Gas)t).wall)
cpt++;
}
...
}
Offline