double bgcolor =
((Double) world.observer().variables
[world.program().globals().indexOf("BGCOLOR")])
.doubleValue();
for (int i = 0; i < patchCount; i++) {
Patch patch = world.getPatch(i);
int liveNeighbors = 0;
for (AgentSet.Iterator iter = patch.getNeighbors().iterator(); iter.hasNext();) {
if (((Boolean) (((Patch) iter.next()).variables[LIVING_VAR]))
.booleanValue()) {
liveNeighbors++;
}
}
patch.variables[LIVE_NEIGHBORS_VAR] = Double.valueOf(liveNeighbors);
}
for (int i = 0; i < patchCount; i++) {
Patch patch = world.getPatch(i);
int liveNeighbors =
((Double) patch.variables[LIVE_NEIGHBORS_VAR]).intValue();
if (liveNeighbors == 3) {
patch.variables[LIVING_VAR] = Boolean.TRUE;
patch.pcolor(fgcolor);
} else if (liveNeighbors != 2) {
patch.variables[LIVING_VAR] = Boolean.FALSE;
patch.pcolor(bgcolor);
}
}
world.tickCounter.tick(1);
context.ip = next;
}