static bool TestPlay() { int[] wins = new int[2]; GoPosition p = Play(false); wins[0] = trainer.Judge(game.Result()); Console.WriteLine(Output(GameBase.Color.Empty, p, game, false)); p = Play(true); wins[1] = trainer.Judge(game.Result()); Console.WriteLine(Output(GameBase.Color.Empty, p, game, false)); return(wins[0] == 0 && wins[1] == 1); GoPosition Play(bool reverse) { game.Reset(); Player first, second; GameBase.Position played = game.Shape.Passed(); if (reverse) { first = trainer.Opponent; second = trainer.Trainee; } else { first = trainer.Trainee; second = trainer.Opponent; } first.color = GameBase.Color.Black; second.color = GameBase.Color.White; while (!game.Ended()) { int turn = game.History.Count; played = first.Play(); if (!game.Ended()) { played = second.Play(); } } return((GoPosition)played); } }
static void Main(string[] args) { boardShape = new GoShape(9); game = new Go(boardShape); int mostRecent = AdaptiveGameAI.Program.GetMostRecent(); AI = new Player(game, GameBase.Color.Black, AdaptiveGameAI.Program.savePath + mostRecent + ".dat"); Tests(); while (!game.Ended()) { GoPosition p = (GoPosition)AI.Play(); Console.WriteLine(AdaptiveGameAI.Program.Output(GameBase.Color.Black, p, game, true)); if (!game.Ended()) { p = HumanPlay(); Console.WriteLine(AdaptiveGameAI.Program.Output(GameBase.Color.White, p, game, true)); } } }