示例#1
0
        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);
            }
        }