public static State4 RunNStates4(string initial, int cycles) { var state = new State4(initial); for (int i = 0; i < cycles; i++) { state = new State4(state); } return(state); }
public State4(State4 prevState) { var activeCells = new HashSet <IVec4>(); foreach (var cur in prevState.PotentialNextCells) { int neighbors = prevState.NeighborsAt(cur); bool wasActive = prevState.ActiveCells.Contains(cur); if ((wasActive && neighbors >= 2 && neighbors <= 3) || (!wasActive && neighbors == 3)) { activeCells.Add(cur); } } ActiveCells = activeCells; }