Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private IOthelloAgent GetAgent()
        {
            AgentDict dict = new AgentDict();
            Type      agentType;

            dict.AgentDictionary.TryGetValue(AgentSelectComboBox.SelectedItem.ToString(), out agentType);
            IOthelloAgent agent;

            if (agentType == typeof(MinMaxAgent))
            {
                Type subAgentType;
                dict.AgentDictionary.TryGetValue(MinMaxAgentComboBox.SelectedItem.ToString(), out subAgentType);
                agent = new MinMaxAgent((IEvaluationAgent)Activator.CreateInstance(subAgentType));
            }
            else
            {
                agent = (IOthelloAgent)Activator.CreateInstance(agentType);
            }
            return(agent);
        }