Пример #1
0
        private void TakeTurn(GameBoard board, GameBoard aiBoard, Player player)
        {
            bool validMove;
            int  row;
            int  col;

            do
            {
                if (player.myType == "Human")
                {
                    row = SelectRow(board);
                    col = SelectColumn(board);
                }
                else if (player.myType == "Computer" && currentPlayer.mySkill == "Amateur")
                {
                    Random rand = new Random();
                    row = rand.Next(board.rows);
                    col = rand.Next(board.cols);
                }
                else if (player.myType == "Computer" && currentPlayer.mySkill == "Expert")
                {
                    AI.ExpertMove(board, aiBoard, player, this, out row, out col);
                }
                else
                {
                    //Skip Turn
                    return;
                }
                validMove = PlacePiece(board, row, col, player);
            } while (!validMove);
            if (CheckForWin(board, row, col, player.myPiece))
            {
                gameOver = true;
                board.DrawGameBoard();
                Console.WriteLine(" Game over! {0} Wins!", player.myPiece);
                return;
            }
            if (CheckForDraw(board))
            {
                gameOver = true;
                board.DrawGameBoard();
                Console.WriteLine(" The game is a draw!");
                return;
            }
            return;
        }