public static string Compute(int i)
        {
            Divider  = new DivisibleRules();
            Contener = new ContentRules();
            string message = string.Empty;

            message = Divider.Apply(i);
            message = message += Contener.Apply(i);
            return(string.IsNullOrEmpty(message) ? i.ToString() : message);
        }
Exemple #2
0
        public void NextGeneration()
        {
            int boardSize = board.Size;

            // A temp variable to hold the next state while it's being calculated.
            bool[,] newBoard = new bool[boardSize, boardSize];

            for (var y = 0; y < boardSize; y++)
            {
                for (var x = 0; x < boardSize; x++)
                {
                    var n = countLiveNeighbors(x, y, boardSize);
                    var c = board.GetCell(x, y);
                    newBoard[x, y] = _gameRules.Apply(c, n);
                }
            }
            // Set the board to its new state.
            board.Update(newBoard);
        }