예제 #1
0
        private static void doTurn()
        {
            GameLogic.CountScore(s_GameBoard);
            s_GameBoard.SwitchTurn();
            GameLogic.MarkLegalMoves(s_GameBoard);
            turnIsOk();

            if (s_IsBot && !s_GameBoard.GameIsFinish && s_GameBoard.Turn == eTurn.Computer && GameLogic.CountLegalMoves(s_GameBoard) != 0)
            {
                while (s_GameBoard.Turn == eTurn.Computer && !s_GameBoard.GameIsFinish)
                {
                    GameLogic.MarkLegalMoves(s_GameBoard);
                    GameLogic.BotMove(s_GameBoard);
                    turnIsOk();
                    GameLogic.MarkLegalMoves(s_GameBoard);
                    GameLogic.CountScore(s_GameBoard);
                }
            }

            if (GameLogic.IsGameOver(s_GameBoard) && s_GameBoard.GameIsFinish != true)
            {
                GetResultFromUser();
                GameLogic.CountScore(s_GameBoard);
            }
        }
예제 #2
0
        public static void BotMove(GameBoard i_Board)
        {
            Random random = new Random();
            int    row = 0, col = 0;

            do
            {
                row = random.Next(0, i_Board.Size);
                col = random.Next(0, i_Board.Size);
            }while (!CheckIfLegalMove(row, col, i_Board));

            i_Board.MatrixButton[row, col].BackColor = i_Board.TurnColor;
            i_Board.MatrixButton[row, col].Text      = "O";
            i_Board.MatrixButton[row, col].Enabled   = false;
            ChangeColorOnBoard(i_Board.TurnColor, row, col, i_Board);
            i_Board.SwitchTurn();
        }