/// <summary> /// Processes the board through a new generation. /// </summary> public LifePoint[,] GetAndUpdateNewGeneration() { // create a new board var newBoard = new LifePoint[_xCount, _yCount]; // loop through the old list for (var x = 0; x < _gameBoard.GetLength(0); x++) { for (var y = 0; y < _gameBoard.GetLength(1); y++) { var lifePoint = _gameBoard[x, y]; var isAlive = lifePoint.GetNextGenerationResult(); var point = lifePoint.Point; var boardPoint = new LifePoint(this, new Point(x, y), isAlive); newBoard[x, y] = boardPoint; } } // update the board _gameBoard = newBoard; // return the new board! return(newBoard); }
/// <summary> /// Initialise the GameBoard. /// </summary> private void InitialiseGameBoard() { _gameBoard = new LifePoint[_xCount, _yCount]; for (var x = 0; x < _xCount; x++) { for (var y = 0; y < _yCount; y++) { var point = new LifePoint(this, new Point(x, y)); _gameBoard[x, y] = point; } } }