Esempio n. 1
0
        public string ValueAtNextGeneration(Cell cell)
        {
            var numberOfNeighbors = CountOfValuesAdjacentToLocation(cell);

            if (cell.IsAliveInThis(Grid) && HasTooFewOrTooManyNeighbors(numberOfNeighbors))
            {
                return(DeadCell);
            }

            if (cell.IsAliveInThis(Grid) && cell.ShouldLiveOnWithThisNumberOfNeighbors(numberOfNeighbors))
            {
                return(LiveCell);
            }

            if (cell.IsDeadInThis(Grid) && HasTooFewOrTooManyNeighbors(numberOfNeighbors))
            {
                return(LiveCell);
            }

            return(DeadCell);
        }