Example #1
0
        public static void LearnTheAgent(int timeInMs, double expFactor, string firstXml)
        {
            var masterMcts = new Mcts(timeInMs, expFactor);
            var weakerMcts = new Mcts(timeInMs, expFactor);

            masterMcts.LoadFromXml(firstXml);
            var tempFile   = string.Empty;
            var masterWins = 0;

            for (int i = 0; i < 100; i++)
            {
                tempFile = $"temp{i}.xml";
                masterMcts.SaveToXml(tempFile);

                if (SimulateGame(masterMcts, weakerMcts) == GameState.Player1Win)
                {
                    masterWins += 1;
                }

                masterMcts.BackToRoot();
                weakerMcts.LoadFromXml(tempFile);
            }

            File.WriteAllText("LearningResult.txt", $"Master won {masterWins} times");
        }