Exemple #1
0
 public TicTacToeBoard(TicTacToeGameModel parent)
 {
     Parent  = parent;
     Squares = new TicTacToeSqaure[3, 3];
     for (int i = 0; i < 3; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             Squares[i, j] = new TicTacToeSqaure(this, i, j);
         }
     }
 }
Exemple #2
0
 public TicTacToeBoard(TicTacToeGameModel parent, TicTacToeBoard board)
 {
     Parent  = parent;
     Squares = new TicTacToeSqaure[3, 3];
     for (int i = 0; i < 3; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             Squares[i, j] = new TicTacToeSqaure(this, i, j);
             Squares[i, j].CurrentStatus = board.Squares[i, j].CurrentStatus;
         }
     }
 }
Exemple #3
0
 public void Play(TicTacToeGameModel ticTacToeGameModel)
 {
     if (PlayerType == PlayerType.Computer)
     {
         // don't allow keyboard inputs
         ticTacToeGameModel.AllowMouseInput = false;
         // do AI move
         MoveModel move = null;
         try
         {
             move = AI.AIUtilities.GetBestMove(ticTacToeGameModel);
         }
         catch (Exception e)
         {
             //Unable to get best move;
             Console.WriteLine("Error in getting best move");
         }
         ticTacToeGameModel.PlaySquare(move.Row, move.Column);
     }
     else
     {
         // wait for human
     }
 }