Example #1
0
        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);
        }
Example #2
0
        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;
        }