private void logCellDetails(int x, int y, Grid.Cell presentCell, int livingNeighborsCount) { String status = presentCell.isAlive() ? "alive" : "dead"; log("Cell (%d,%d) is %s and has %d living neighbor(s).", x, y, status, livingNeighborsCount); }
private void applyRule4(Grid.Cell presentCell, Grid.Cell futureCell, int livingNeighborsCount) { if (presentCell.isDead() && livingNeighborsCount == 3) { log("...lives in next generation :-) (reproduction)"); futureCell.reproduce(); } }
private void applyRule2(Grid.Cell presentCell, Grid.Cell futureCell, int livingNeighborsCount) { if (presentCell.isAlive() && (livingNeighborsCount == 2 || livingNeighborsCount == 3)) { log("...lives in next generation :-)"); futureCell.reproduce(); } }
private void applyRule3(Grid.Cell presentCell, Grid.Cell futureCell, int livingNeighborsCount) { if (presentCell.isAlive() && livingNeighborsCount > 3) { log("...dies in next generation :-( (overcrowding)"); futureCell.die(); } }
private void applyRule1(Grid.Cell presentCell, Grid.Cell futureCell, int livingNeighborsCount) { if (presentCell.isAlive() && livingNeighborsCount < 2) { log("...dies in next generation :-( (under-population)"); futureCell.die(); } }