private static void TestFight() { var ai1 = new MCTS(); var ai2 = new MCTS(); var i = 0; var lose = 0; var win = 0; var count = 100000; while (i++ < count) { Console.WriteLine($"{i}. now: {DateTime.Now}"); var game = new Game(); var player = 1; //Console.WriteLine(game); do { var bestmove = ai1.GetBestMove(game, player); //Console.WriteLine($"p1 best move: {bestmove}"); Console.Write(bestmove); game.Mark(player, bestmove); //change player player = 3 - player; if (!game.Over()) { //bestmove = ai2.RandomMove(game, player); bestmove = ai2.GetBestMove_RealtimeTraining(game, player); //Console.WriteLine($"p2 best move: {bestmove}"); Console.Write(bestmove); game.Mark(player, bestmove); } //change player player = 3 - player; }while (!game.Over()); var winner = game.GetWinner(); if (winner == 1) { lose++; } else if (winner == 2) { win++; } Console.WriteLine($" winner:{winner} score: {lose}-{win}"); //Console.WriteLine(game); } }
private static void TestMCTS2() { var mcts = new MCTS(); var i = 0; while (i < 1000) { Console.WriteLine("now: {0}", DateTime.Now); mcts.Train(i++); } }
private static void TestMCTS() { var game = new Game(); var mcts = new MCTS(); var player = 1; Console.WriteLine(game); do { var bestmove = mcts.GetBestMove(game, player); Console.WriteLine($"best move: {bestmove}"); game.Mark(player, bestmove); Console.WriteLine(game); //change player player = 3 - player; }while (!game.Over()); }