Ejemplo n.º 1
0
 public ComputerPlayer(sbyte team, Personality personality, Difficulty difficulty, BoardView boardView)
     : base(team, false, boardView)
 {
     Difficulty         = difficulty;
     Personality        = personality;
     maxNAlgorithm      = new MaxN(boardView.Board);
     paranoidAlgorithm  = new Paranoid(boardView.Board);
     offensiveAlgorithm = new Offensive(boardView.Board);
     mixAlgorithm       = new MPMix(boardView.Board, 0.5, 0.5);
     mctsAlgorithm      = new MCTS(boardView.Board);
 }
Ejemplo n.º 2
0
        public static sbyte SimulateGame()
        {
            Board     board     = new Board();
            Algorithm mpMix     = new MPMix(board, 1, 0.5);
            Algorithm maxN      = new MaxN(board);
            Algorithm paranoid  = new Paranoid(board);
            Algorithm offensive = new Offensive(board);
            Algorithm mcts      = new MCTS(board);

            int   doublesCount = 0;
            sbyte lastTeam     = 0;
            sbyte team         = 0;
            int   turns        = 0;

            while (!board.IsGameOver())
            {
                Console.Title = turns.ToString();
                lastTeam      = team;

                DiceRoll roll = board.GetRandomRoll();
                Move     m    = null;
                switch (team)
                {
                case 0:
                    m = board.ThinkBest(mcts, roll, team, 0);
                    break;

                case 1:
                    m = board.ThinkBest(maxN, roll, team, 0);
                    break;

                case 2:
                    m = board.ThinkBest(mcts, roll, team, 0);
                    break;

                case 3:
                    m = board.ThinkBest(mcts, roll, team, 0);
                    break;
                }
                if (m != null)
                {
                    board.PerformMove(m);
                }

                if (roll.IsDoubles())
                {
                    doublesCount++;
                    if (doublesCount >= 3)
                    {
                        board.RemoveFrontMarble(team);
                        doublesCount = 0;
                        team         = board.NextPlayer(team);
                        turns++;
                    }
                }
                else
                {
                    doublesCount = 0;
                    team         = board.NextPlayer(team);
                    turns++;
                }
            }

            Console.WriteLine("{0} won ({1} turns)", GetName(lastTeam), turns);
            return(lastTeam);
        }