Пример #1
0
 public void enableAllButtons()
 {
     for (int r = 0; r < GD.getNumRows(); r++)
     {
         for (int c = 0; c < GD.getNumCols(); c++)
         {
             if (GD.getGameBoardCell(r, c).getValue() == '-')
             {
                 GD.getGameBoardCell(r, c).getButton().Enabled = true;
             }
         }
     }
 }
Пример #2
0
        public void findMove()
        {
            char[,] minimaxBoard = new char[main_GD.getNumRows(), main_GD.getNumCols()];
            getPossibleMoves();
            //randomMove();
            copyArray(minimaxBoard);
            int  bestScore = Int32.MinValue;
            Cell bestMove  = new Cell();


            //cycle through all possible moves that AI could make
            for (int r = 0; r < main_GD.getNumRows(); r++)
            {
                for (int c = 0; c < main_GD.getNumCols(); c++)
                {
                    if (minimaxBoard[r, c] == '-')
                    {
                        minimaxBoard[r, c]  = main_GD.getAICharacter();
                        lastCharacterPlaced = main_GD.getAICharacter();
                        dispBoardCopy(minimaxBoard);
                        int score = miniMaxAlgorithm(minimaxBoard, 0, false);
                        minimaxBoard[r, c] = '-';
                        if (score > bestScore)
                        {
                            //Console.WriteLine("HERE");
                            bestScore = score;
                            bestMove  = main_GD.getGameBoard()[r, c];
                            Console.WriteLine(r + ", " + c);
                        }

                        // break;
                    }
                }
            }
            Console.WriteLine(bestScore);
            makeMove(bestMove);
        }