コード例 #1
0
ファイル: GuiController.cs プロジェクト: tsschaffert/hexdame
 public void UpdateGui(Gameboard gameboard)
 {
     if (gui.Created)
     {
         gui.BeginInvoke(new InvokeDelegateUpdateGui(gui.UpdateGui), new object[] { gameboard });
     }
 }
コード例 #2
0
ファイル: Gameboard.cs プロジェクト: tsschaffert/hexdame
        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);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: Gameboard.cs プロジェクト: tsschaffert/hexdame
 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);
 }
コード例 #5
0
ファイル: Gui.cs プロジェクト: tsschaffert/hexdame
 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;
         }
     }
 }
コード例 #6
0
        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)
            {
            }
        }
コード例 #7
0
        /// <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();
        }
コード例 #8
0
ファイル: GameLogic.cs プロジェクト: tsschaffert/hexdame
 public GameLogic(Gameboard gameboard)
 {
     this.gameboard = gameboard;
 }