예제 #1
0
        private GameBoard(GameBoard original)
        {
            gameover = original.gameover;
            cells = new int[8, 8];

            for (int x = 0; x < 8; ++x)
            {
                for (int y = 0; y < 8; ++y)
                {
                    cells[x, y] = original.cells[x, y];
                }
            }

            currentTurn = original.currentTurn;
            whiteScore = original.whiteScore;
            blackScore = original.blackScore;
        }
예제 #2
0
        public GameBoard makeMove(int x, int y)
        {
            GameBoard output = new GameBoard(this);

            output.playAtPosition(x, y);

            return output;
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            updateMousePosition();
            dealWithUserClicks(gameTime);

            if (timeForAIMove(gameTime))
            {
                if (aiThread == null)
                {
                    ais[selectedAI].storedBoard = board;
                    aiThread = new Thread(ais[selectedAI].getDesiredMove);
                    aiThread.Start();

                    this.lastPlayTime = gameTime.TotalGameTime.TotalSeconds;
                }
                else if (aiThread.ThreadState == ThreadState.Stopped && gameTime.TotalGameTime.TotalSeconds - lastPlayTime > waitTimeSeconds)
                {
                    board = board.makeMove(ais[selectedAI].desiredMove.X, ais[selectedAI].desiredMove.Y);
                    aiThread = null;
                }
            }
        }
예제 #4
0
 public GameBoardManager(Game game)
     : base(game)
 {
     board = new GameBoard();
 }
예제 #5
0
        private void newGame()
        {
            board = new GameBoard();

            if (aiThread != null)
            {
                aiThread.Abort();
                aiThread = null;
            }
        }
예제 #6
0
 private bool attemptToMakePlay()
 {
     if (board.validPosition(highlightedX, highlightedY) &&
         board.canPlayAtPosition(highlightedX, highlightedY))
     {
         board = board.makeMove(highlightedX, highlightedY);
         return true;
     }
     else
         return false;
 }