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); }
internal CheckerColor Run() { while (!TemporalDifference.GameOver(st)) { var outcome = PickBestOutcome(); if (outcome == null) { game.EndTurn(game.playerToMove()); } else { for (int i = 0; i < outcome.movesMade.Count; i++) { game.Move(game.playerToMove(), outcome.movesMade[i].from, outcome.movesMade[i].to); } TemporalDifference.UpdateWeights(st, outcome.state, game.playerToMove()); st = outcome.state; } } TemporalDifference.UpdateWeights(st, st, White); TemporalDifference.UpdateWeights(st, st, Black); // st1 doesn't matter when game is won. return((game.GetGameBoardState().getCheckersOnTarget(White) == 15) ? White : Black); }
internal void MakeMoveAndLearn() { MakeMove(); TemporalDifference.UpdateWeights(st, outcome.state, game.playerToMove()); }