public OthelloGui(OthelloBoard othelloBoard) { InitializeComponent(); _othelloBoard = othelloBoard; _n = _othelloBoard.N; _m = _othelloBoard.M; _availableMoves = _othelloBoard.AvailableMoves(_othelloBoard.Turn); turnBox.BackColor = _othelloBoard.Turn == 1 ? Color.Black : Color.White; _minimax = new Minimax(3, false); aiPlayTimer.Enabled = true; }
private void UpdateBoardGui() { blackCountLabel.Text = "Blacks: " + _othelloBoard.Player1Pos.Count; whiteCountLabel.Text = "Whites: " + _othelloBoard.Player2Pos.Count; var blacks = ""; var whites = ""; foreach (var black in _othelloBoard.Player1Pos) { blacks += "(" + black.Item1 + "," + black.Item2 + ")" + '\n'; } foreach (var white in _othelloBoard.Player2Pos) { whites += "(" + white.Item1 + "," + white.Item2 + ")" + '\n'; } whitesList.Text = whites; blacksList.Text = blacks; board.Invalidate(); for (var i = 0; i < 2; i++) { _othelloBoard.Turn = _othelloBoard.Turn == 1 ? 2 : 1; _othelloBoard.Flips.Clear(); _availableMoves = _othelloBoard.AvailableMoves(_othelloBoard.Turn); turnBox.BackColor = _othelloBoard.Turn == 1 ? Color.Black : Color.White; if (_availableMoves.Count > 0) { return; } } MessageBox.Show("Game Ended", "Result"); }