public void UpdateGui(Gameboard gameboard) { if (gui.Created) { gui.BeginInvoke(new InvokeDelegateUpdateGui(gui.UpdateGui), new object[] { gameboard }); } }
public object Clone() { Gameboard ret = new Gameboard(); for (int i = 0; i < gameboard.Length; i++) { for (int j = 0; j < gameboard[i].Length; j++) { ret.gameboard[i][j] = (Cell)this.gameboard[i][j].Clone(); } } ret.CurrentPlayer = CurrentPlayer; return(ret); }
public Game(GuiController guiController) { gameboard = new Gameboard(); gameLogic = new GameLogic(gameboard); // The evaluator class can be used to get a comparison regarding the win rate for several players /*evaluator = new Evaluator(this, * new AlphaBetaPlayer(Player.White, 1, new Evaluation(Player.White, 1000, 1500, 50, 50, 0)), * new AlphaBetaPlayer(Player.White, 1, new Evaluation(Player.White, 1000, 2000, 50, 50, 0)));*/ evaluator = new Evaluator(this); this.guiController = guiController; players = new AbstractPlayer[NUMBER_OF_PLAYERS]; timerNextMove = new Timer(PAUSE_BETWEEN_MOVES); timerNextMove.Elapsed += timerNextMove_Elapsed; timerNextMove.AutoReset = false; }
public override bool Equals(object obj) { if (obj is Gameboard) { Gameboard other = (Gameboard)obj; for (int i = 0; i < gameboard.Length; i++) { for (int j = 0; j < gameboard[i].Length; j++) { if (gameboard[i][j].Content != other.gameboard[i][j].Content) { return(false); } } } return(this.CurrentPlayer == other.CurrentPlayer); } return(false); }
public void UpdateGui(Gameboard gameboard) { foreach (HexdameButton button in playButtons) { button.Text = gameboard.GetCell(button.FieldPosition).Content.ToString(); button.Checked = false; if (gameboard.GetCell(button.FieldPosition).ContainsWhite) { button.BackColor = Color.White; } else if (gameboard.GetCell(button.FieldPosition).ContainsRed) { button.BackColor = Color.Red; } else { button.BackColor = Color.Transparent; } } }
private void LoadState() { if (evaluator.IsActive) { // Too many file accesses return; } try { using (Stream stream = new FileStream("last_state.xml", FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); gameboard = (Gameboard)bf.Deserialize(stream); gameLogic = new GameLogic(gameboard); } } catch (Exception e) { } }
/// <summary> /// Resets the game board and players and starts the game /// </summary> public void NewGame() { gameboard = new Gameboard(); gameLogic = new GameLogic(gameboard); // Loading of game state disabled /*if (firstGame) * { * firstGame = false; * LoadState(); * }*/ currentRound = 0; players[(int)Player.White] = new HumanPlayer(Player.White); players[(int)Player.Red] = new AlphaBetaFinalPlayer(Player.Red, 6); guiController.UpdateGui((Gameboard)gameboard.Clone()); timerNextMove.Stop(); timerNextMove.Start(); }
public GameLogic(Gameboard gameboard) { this.gameboard = gameboard; }