Beispiel #1
0
 public GameLogic(int width, int height, int stepsAI1, int stepsAI2)
 {
     this.Width  = width;
     this.Height = height;
     Board       = new Board();
     ai1         = new AI(stepsAI1);
     ai2         = new AI(stepsAI2);
     Visuals     = new CreateVisuals(Board, width, height);
     Bitmap      = Visuals.output;
 }
Beispiel #2
0
 public void Move(int column, Player player)
 {
     try
     {
         Board.Update(column, player);
         Visuals = new CreateVisuals(Board, Width, Height);
         Bitmap  = Visuals.output;
     }
     catch
     {
         if (Board.OpenColumns.Count == 0)
         {
             MessageBox.Show("It's a draw.", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             GameOver = true;
         }
         else
         {
             MessageBox.Show("This row is full.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             Retry = true;
         }
     }
 }
Beispiel #3
0
 public void ComputerMove(Player player)
 {
     try
     {
         Move move = new Move();
         if (player == Player.One)
         {
             move = ai1.BestMove(Board, player);
         }
         else
         {
             move = ai2.BestMove(Board, player);
         }
         Board.Update(move.X, player);
         Visuals = new CreateVisuals(Board, Width, Height);
         Bitmap  = Visuals.output;
     }
     catch
     {
         MessageBox.Show("It's a draw.", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         GameOver = true;
     }
 }