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); }
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(); }
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); }