private void SetupGame() { _myGame.ResetBoard(); _myAgent = GetAgent(); _myPlayer = PlayerSelectComboBox.SelectedItem.ToString() == BoardStates.white.ToString() ? BoardStates.black : BoardStates.white; _boardPanels = new PiecePanel[OthelloGame.BOARD_SIZE, OthelloGame.BOARD_SIZE]; int tileSize = ((Size.Width > Size.Height) ? Size.Height - 45 : Size.Width - 45) / OthelloGame.BOARD_SIZE; for (int i = 0; i < OthelloGame.BOARD_SIZE; i++) { for (int j = 0; j < OthelloGame.BOARD_SIZE; j++) { var newPanel = new PiecePanel(new int[] { i, j }) { Size = new Size(tileSize, tileSize), Location = new Point(tileSize * i, tileSize * j) }; newPanel.MouseClick += new MouseEventHandler(OthelloPeice_Click); Controls.Add(newPanel); _boardPanels[i, j] = newPanel; Color panelcolor = Color.Red; if (BoardColorDictionary.BoardStateColors.TryGetValue(_myGame.GetBoard()[i, j], out panelcolor)) { _boardPanels[i, j].ReColor(panelcolor); } } } if (_myGame.WhosTurn != _myPlayer) { _myGame.MakeMove(_myAgent.MakeMove(_myGame, ~_myPlayer)); } }
private void SetupBoard() { _myGame = new OthelloGame(); _minMaxAgent = new MinMaxAgent(); _boardPanels = new PiecePanel[OthelloGame.BOARD_SIZE, OthelloGame.BOARD_SIZE]; _currentViewedMove = 0; int tileSize = ((Size.Width > Size.Height) ? Size.Height - 45 : Size.Width - 45) / OthelloGame.BOARD_SIZE; for (int i = 0; i < OthelloGame.BOARD_SIZE; i++) { for (int j = 0; j < OthelloGame.BOARD_SIZE; j++) { var newPanel = new PiecePanel(new int[] { i, j }) { Size = new Size(tileSize, tileSize), Location = new Point(tileSize * i, tileSize * j) }; newPanel.MouseClick += new MouseEventHandler(OthelloPeice_Click); Controls.Add(newPanel); _boardPanels[i, j] = newPanel; Color panelcolor = Color.Red; if (BoardColorDictionary.BoardStateColors.TryGetValue(_myGame.GetBoard()[i, j], out panelcolor)) { _boardPanels[i, j].ReColor(panelcolor); } } } }
private void RefreshControls() { for (int i = 0; i < OthelloGame.BOARD_SIZE; i++) { for (int j = 0; j < OthelloGame.BOARD_SIZE; j++) { Color color; BoardColorDictionary.BoardStateColors.TryGetValue(_myGame.GetBoard()[i, j], out color); _boardPanels[i, j].ReColor(color); _currentViewedMove = _myGame.GetMovesMade(); } } if (_myGame.GameComplete) { GameOverLabel.Visible = true; _twoSecondTimer.Elapsed += new System.Timers.ElapsedEventHandler(GameOver_VisibilityFalse); _twoSecondTimer.Enabled = true; } }