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; }
public GameBoard makeMove(int x, int y) { GameBoard output = new GameBoard(this); output.playAtPosition(x, y); return output; }
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; } } }
public GameBoardManager(Game game) : base(game) { board = new GameBoard(); }
private void newGame() { board = new GameBoard(); if (aiThread != null) { aiThread.Abort(); aiThread = null; } }
private bool attemptToMakePlay() { if (board.validPosition(highlightedX, highlightedY) && board.canPlayAtPosition(highlightedX, highlightedY)) { board = board.makeMove(highlightedX, highlightedY); return true; } else return false; }