Patch parent = (Patch) context.agent;
int numberOfTurtles = argEvalIntValue(context, 0);
org.nlogo.util.MersenneTwisterFast random = context.job.random;
if (numberOfTurtles > 0) {
AgentSet agentset =
new ArrayAgentSet(Turtle.class, numberOfTurtles,
false, world);
if (breedName == NO_BREED) {
for (int i = 0; i < numberOfTurtles; i++) {
Turtle child = parent.sprout
(random.nextInt(14), random.nextInt(360), world.turtles());
agentset.add(child);
workspace.joinForeverButtons(child);
}
} else {
AgentSet breed = world.getBreed(breedName);
for (int i = 0; i < numberOfTurtles; i++) {
Turtle child = parent.sprout
(random.nextInt(14), random.nextInt(360), breed);
agentset.add(child);
workspace.joinForeverButtons(child);
}
}
context.runExclusiveJob(agentset, next);
}