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; } } }
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; } }