コード例 #1
0
ファイル: GameBoard.cs プロジェクト: rodya-mirov/Othello
        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
ファイル: GameBoard.cs プロジェクト: rodya-mirov/Othello
        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;
 }