示例#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);
            }
        }
示例#2
0
        public static string Output(GameBase.Color playercolor, GoPosition move, Go game, bool printBoard)
        {
            int[]         result = game.Result();
            StringBuilder text   = new StringBuilder("\n");

            text.Append("- Move ");
            text.Append(game.History.Count);
            text.Append(", after ");
            text.Append(playercolor.ToString());
            text.Append(" played at ");
            text.Append(move.Y + 1);
            text.Append(", ");
            text.Append(9 - move.X);
            if (printBoard)
            {
                text.Append(game.Print());
            }
            text.AppendLine();
            text.Append("Score: ");
            text.Append(result[0]);
            text.Append(" to ");
            text.Append(result[1]);
            return(text.ToString());
        }