}//c-tor #endregion /// <summary> ///Play a game /// </summary> public void Play() { UIManager.PrintHeader();//show header Move newMove; do { do { UIManager.PrintEmptyBoard(_board.GameBoard); //show help game board newMove = CurrentPlayer.MakeMove(_board); // player make new move } while (!_board.SetMove(newMove, CurrentPlayer.PlayerSign)); //until move is located _moves.Push(newMove); //save move _board.Check(CurrentPlayer.PlayerSign); //chack for game is over } while (_state == State.CONTINUE); //while game state is continue }//Play
}//c-tor #endregion /// <summary> /// Generate children /// </summary> /// <param name="sign of computer player"></param> public void GenerateChildren(Sign sign) { _children = new List <Node>(); for (byte i = 0; i < _board.IsPositionsOpen.Length; i++) { if (_board.IsPositionsOpen[i] == true) { Move newMove = new Move(i); Board clone = (Board)_board.Clone(); clone.SetMove(newMove, sign); Node newNode = new Node(sign, clone); newNode.Position = i; newNode.Parent = this; _children.Add(newNode); } } }
// Saves the move made by a player public void SaveMove(int x, int y, int value) { gameBoard.SetMove(x, y, value); if (isWinner(x, y)) { aWinningSequenceExists = true; gameStatus = Status.GameFinished; } else if (isTie()) { aTieSequenceExists = true; gameStatus = Status.GameFinished; } else { UpdateCurrentPlayer(); UpdateStatus(); } }