Newer
Older
/**
* {@link GameOfLifeState} instances represent the possible states of a {@link GameOfLifeState}.
*/
public enum GameOfLifeState implements State<GameOfLifeState> {
public GameOfLifeState update(List<GameOfLifeState> neighbors) {
int aliveCount = State.count(ALIVE, neighbors);
if (this == ALIVE) {
return (aliveCount == 2 || aliveCount == 3) ? ALIVE : DEAD;
} else {
return (aliveCount == 3) ? ALIVE : DEAD;