Beispiel #1
0
        static Player LearnVsNaive(int gameCount)
        {
            Player white, black;
            var    game = new BackgammonGame(BackgammonGame.DefaultGameBoard, new RealDice());

            if (gameCount % 2 == 0)
            {
                white = new MachAI(game);
                black = new NaiveAI(game, Black);
            }
            else
            {
                black = new MachAI(game);
                white = new NaiveAI(game, White);
            }
            while (!TemporalDifference.GameOver(game.GetGameBoardState()))
            {
                if (game.playerToMove() == White)
                {
                    white.MakeMove();
                }
                else
                {
                    black.MakeMove();
                }
            }
            TemporalDifference.UpdateWeights(game.GetGameBoardState(), game.GetGameBoardState(), (gameCount % 2 == 0) ? White : Black);
            return((game.GetGameBoardState().getCheckersOnTarget(White) == 15) ? white : black);
        }
Beispiel #2
0
 private void Move(BackgammonGame model, CheckerColor c, Player ai)
 {
     if (ai == null)
     {
         if (naive)
         {
             ai = new NaiveAI(model, c);
         }
         else
         {
             ai = new MachAI(model);
         }
     }
     ai.MakeMove();
 }
Beispiel #3
0
        static CheckerColor PitMachVsNaive(int gameCount)
        { // MachAI
            var    game  = new BackgammonGame(BackgammonGame.DefaultGameBoard, new RealDice());
            Player white = new MachAI(game);
            Player black = new NaiveAI(game, Black);

            while (!TemporalDifference.GameOver(game.GetGameBoardState()))
            {
                if (game.playerToMove() == White)
                {
                    white.MakeMove();
                }
                else
                {
                    black.MakeMove();
                }
            }
            return((game.GetGameBoardState().getCheckersOnTarget(White) == 15) ? White : Black);
        }