Example #1
0
        /// <summary>
        /// 初始化一个黑白棋棋盘, 大小为 8*8. 中间 4 个初始棋子为白黑白黑.
        /// </summary>
        private ReversiGame()
        {
            CurrentBoard = new ReversiPiece[BoardSize, BoardSize];
            for (int i = 0; i < BoardSize; i++)
            {
                for (int j = 0; j < BoardSize; j++)
                {
                    CurrentBoard[i, j] = ReversiPiece.Empty;
                }
            }
            CurrentBoard[BoardSize / 2 - 1, BoardSize / 2 - 1] = ReversiPiece.White;
            CurrentBoard[BoardSize / 2, BoardSize / 2 - 1]     = ReversiPiece.Black;
            CurrentBoard[BoardSize / 2 - 1, BoardSize / 2]     = ReversiPiece.Black;
            CurrentBoard[BoardSize / 2, BoardSize / 2]         = ReversiPiece.White;
            // TODO: 删除用于调试的初始棋局

            /*CurrentBoard[0, 0] = ReversiPiece.Black;
            *  CurrentBoard[0, 1] = ReversiPiece.Black;
            *  CurrentBoard[1, 0] = ReversiPiece.White;
            *  CurrentBoard[1, 1] = ReversiPiece.White;*/
            CurrentGame     = this;
            CurrentPiece    = ReversiPiece.Black;
            LastPiece       = ReversiPiece.White;
            LastPosition    = new ReversiPiecePosition(4, 4);
            TotalSteps      = 0;
            reversiBuffer   = new ReversiBuffer();
            IsBusy          = false;
            isRegretEnabled = false;
            MaxRegretSteps  = 0;
            gameStateStack  = new RecersiGameStateStack();
            UpdateState();
            ResetBuffer();
        }
Example #2
0
 /// <summary>
 /// 初始化一个有特定棋局的黑白棋棋盘, 其棋局由参数确定.
 /// </summary>
 /// <param name="initialReversiBoard">是一个二维数组, 指定黑白棋棋局.</param>
 private ReversiGame(ReversiPiece[,] initialReversiBoard)
 {
     CurrentBoard  = initialReversiBoard;
     CurrentGame   = this;
     CurrentPiece  = ReversiPiece.Black;
     LastPiece     = ReversiPiece.White;
     LastPosition  = new ReversiPiecePosition(4, 4);
     reversiBuffer = new ReversiBuffer();
     IsBusy        = false;
     UpdateState();
     ResetBuffer();
 }
Example #3
0
        public Window1()
        {
            InitializeComponent();
            m_gamePieces  = new Dictionary <Point, Cylinder>();
            m_ghostPieces = new Dictionary <Cylinder, Point>();

            // some animation/UI initialization
            NameScope.SetNameScope(mainViewport, new NameScope());

            ui_dopSlider.Minimum     = 1.0;
            ui_dopSlider.Maximum     = Environment.ProcessorCount * 2;
            ui_dopSlider.Value       = Environment.ProcessorCount;
            ui_depthSlider.Minimum   = 8.0;
            ui_depthSlider.Maximum   = 24.0;
            ui_depthSlider.Value     = 18.0;
            ui_timeoutSlider.Minimum = 1.0;
            ui_timeoutSlider.Maximum = 60.0;
            ui_timeoutSlider.Value   = 8.0;
            m_useAnimation           = true;

            // Set the UI scheduler
            m_UIScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            // Initialize the game
            m_game         = new ReversiGame(8, 8);
            m_isGameOver   = false;
            m_isAIMoving   = false;
            m_isAIParallel = true;
            m_isAuto       = false;

            // Initialize the GUI's board
            m_GUIboard = new MinimaxSpot[8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    m_GUIboard[i, j] = MinimaxSpot.Empty;
                }
            }
            UpdateBoard();
        }
Example #4
0
        private void btStart_Click(object sender, EventArgs e)
        {
            this.gbInGameControls.Visible  = true;                                            // Game controls zichtbaar maken
            this.gbPreGameControls.Visible = false;
            this.Size        = new Size(540, 725);                                            // Form groter maken
            pnBoard.Size     = new Size(500, 500);
            this.boardBitmap = new Bitmap(500, 500);                                          // Bitmap aanmaken
            tbHelp.Value     = ReversiGame.HELP_OFF;                                          // Help standaard uitzetten

            boardBitmapGraphics           = Graphics.FromImage(boardBitmap);                  // Graphics-object om te tekenen
            animateCurrentPlayerIndicator = true;
            Thread currentPlayerIndicatorThread = new Thread(currentPlayerIndicatorAnimator); // Indicator-animator starten

            currentPlayerIndicatorThread.Start();

            currentGame          = new ReversiGame(boardSizeSelectorPos);
            currentGame.helpMode = tbHelp.Value;

            drawStones();                       // Standaard grid tekenen
            currentGame.setInitialStones();     // Stenen plaatsen
            drawStones();                       // Veranderde stenen tekenen
        }
Example #5
0
        private void btStart_Click(object sender, EventArgs e)
        {
            this.gbInGameControls.Visible = true;                           // Game controls zichtbaar maken
            this.gbPreGameControls.Visible = false;
            this.Size = new Size(540, 725);                                 // Form groter maken
            pnBoard.Size = new Size(500, 500);
            this.boardBitmap = new Bitmap(500, 500);                        // Bitmap aanmaken
            tbHelp.Value = ReversiGame.HELP_OFF;                            // Help standaard uitzetten

            boardBitmapGraphics = Graphics.FromImage(boardBitmap);          // Graphics-object om te tekenen
            animateCurrentPlayerIndicator = true;
            Thread currentPlayerIndicatorThread = new Thread(currentPlayerIndicatorAnimator);   // Indicator-animator starten
            currentPlayerIndicatorThread.Start();

            currentGame = new ReversiGame(boardSizeSelectorPos);
            currentGame.helpMode = tbHelp.Value;

            drawStones();                       // Standaard grid tekenen
            currentGame.setInitialStones();     // Stenen plaatsen
            drawStones();                       // Veranderde stenen tekenen
        }
Example #6
0
 public Form1()
 {
     InitializeComponent();
     game = new ReversiGame(reversiBoard1);
 }