Ejemplo n.º 1
0
        public static int ConsoleGTP(MemFile file, bool loadSilent)
        {
            GoBoard        lGoBoard        = new GoBoard(9);
            GTPGoBoard     lGTPGoBoard     = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine      lGTPEngine      = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPCommConsole.Silent = loadSilent;

            if (file != null)
            {
                while (!file.EOF)
                {
                    string lLine = file.ReadLine();
                    Console.Error.WriteLine(lLine.Trim('\n'));
                    lGTPCommConsole.SendToEngine(lLine + '\n');
                }
            }

            lGTPCommConsole.Silent = false;

            lGTPCommConsole.Listen();

            return(0);
        }
Ejemplo n.º 2
0
        public static int ConnectToCGOS(string name, string pPwd, int pNbr)
        {
            GoBoard lGoBoard = new GoBoard(9);
            GTPGoBoard lGTPGoBoard = new GTPGoBoard(lGoBoard);
            GTPCommCGOS lGTPCommCGOS = new GTPCommCGOS("cgos.boardspace.net", 6867, name, pPwd, pNbr, true);
            GTPEngine lGTPEngine = new GTPEngine(lGTPGoBoard, lGTPCommCGOS);

            lGTPCommCGOS.Run();

            return 0;
        }
Ejemplo n.º 3
0
        public static int ConnectToCGOS(string name, string pPwd, int pNbr)
        {
            GoBoard     lGoBoard     = new GoBoard(9);
            GTPGoBoard  lGTPGoBoard  = new GTPGoBoard(lGoBoard);
            GTPCommCGOS lGTPCommCGOS = new GTPCommCGOS("cgos.boardspace.net", 6867, name, pPwd, pNbr, true);
            GTPEngine   lGTPEngine   = new GTPEngine(lGTPGoBoard, lGTPCommCGOS);

            lGTPCommCGOS.Run();

            return(0);
        }
Ejemplo n.º 4
0
        public static int Debug()
        {
            GoBoard        lGoBoard        = new GoBoard(9);
            GTPGoBoard     lGTPGoBoard     = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine      lGTPEngine      = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPEngine.Receive("boardsize 9\n");
            lGTPEngine.Receive("gogui-play_sequence b A3 b A5 b A6 b A7 b A8 b A9 b B3 b B5 b B9 b C2 b C3 b C4 b C5 b C6 b C7 b D1 b D2 b D4 b D6 b D7 b E5 b E6 b F6 b G3 b G4 b G5 b G6 b G7 b H3 b H5 b H7 b H9 b J5 b J6 b J7 w A1 w A2 w B1 w B2 w B6 w B7 w B8 w C8 w C9 w D3 w D8 w E1 w E2 w E3 w E4 w E7 w E8 w F1 w F3 w F4 w F7 w F8 w F9 w G2 w G8 w G9 w H2 w H4 w H8 w J1 w J2 w J3 w J4 w J8\n");
            lGTPEngine.Receive("play b PASS\n");
            lGTPEngine.Receive("showboard\n");
            lGTPEngine.Receive("top_moves white\n");

            //			lGTPCommConsole.Listen();

            return(0);
        }
Ejemplo n.º 5
0
        public static int SelfPlay()
        {
            GoBoard        lGoBoard        = new GoBoard(19);
            GTPGoBoard     lGTPGoBoard     = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine      lGTPEngine      = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPEngine.Receive("boardsize 9\n");

            while (!lGoBoard.GameOver)
            {
                lGTPCommConsole.SendToEngine("genmove b\n");
                lGTPCommConsole.SendToEngine("showboard\n");
                lGTPCommConsole.SendToEngine("genmove w\n");
                lGTPCommConsole.SendToEngine("showboard\n");
            }

            return(0);
        }
Ejemplo n.º 6
0
        public static int ConsoleGTP(MemFile file, bool loadSilent)
        {
            GoBoard lGoBoard = new GoBoard(9);
            GTPGoBoard lGTPGoBoard = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine lGTPEngine = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPCommConsole.Silent = loadSilent;

            if (file != null)
                while (!file.EOF)
                {
                    string lLine = file.ReadLine();
                    Console.Error.WriteLine(lLine.Trim('\n'));
                    lGTPCommConsole.SendToEngine(lLine + '\n');
                }

            lGTPCommConsole.Silent = false;

            lGTPCommConsole.Listen();

            return 0;
        }
Ejemplo n.º 7
0
        public static int SelfPlay()
        {
            GoBoard lGoBoard = new GoBoard(19);
            GTPGoBoard lGTPGoBoard = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine lGTPEngine = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPEngine.Receive("boardsize 9\n");

            while (!lGoBoard.GameOver)
            {
                lGTPCommConsole.SendToEngine("genmove b\n");
                lGTPCommConsole.SendToEngine("showboard\n");
                lGTPCommConsole.SendToEngine("genmove w\n");
                lGTPCommConsole.SendToEngine("showboard\n");
            }

            return 0;
        }
Ejemplo n.º 8
0
        public static int Debug()
        {
            GoBoard lGoBoard = new GoBoard(9);
            GTPGoBoard lGTPGoBoard = new GTPGoBoard(lGoBoard);
            GTPCommConsole lGTPCommConsole = new GTPCommConsole();
            GTPEngine lGTPEngine = new GTPEngine(lGTPGoBoard, lGTPCommConsole);

            lGTPEngine.Receive("boardsize 9\n");
            lGTPEngine.Receive("gogui-play_sequence b A3 b A5 b A6 b A7 b A8 b A9 b B3 b B5 b B9 b C2 b C3 b C4 b C5 b C6 b C7 b D1 b D2 b D4 b D6 b D7 b E5 b E6 b F6 b G3 b G4 b G5 b G6 b G7 b H3 b H5 b H7 b H9 b J5 b J6 b J7 w A1 w A2 w B1 w B2 w B6 w B7 w B8 w C8 w C9 w D3 w D8 w E1 w E2 w E3 w E4 w E7 w E8 w F1 w F3 w F4 w F7 w F8 w F9 w G2 w G8 w G9 w H2 w H4 w H8 w J1 w J2 w J3 w J4 w J8\n");
            lGTPEngine.Receive("play b PASS\n");
            lGTPEngine.Receive("showboard\n");
            lGTPEngine.Receive("top_moves white\n");

            //			lGTPCommConsole.Listen();

            return 0;
        }
Ejemplo n.º 9
0
 public void SetGTPEngine(GTPEngine gtpEngine)
 {
     GTPEngine = gtpEngine;
 }
Ejemplo n.º 10
0
        public static GTPInternalResponse GTPCGOSConnect(GTPGoBoard gtpGoBoard, GTPCommand gtpCommand)
        {
            if (gtpCommand.GetParameterCount() < 2)
                return MissingParameterResponse();

            string lName = gtpCommand.GetParameter(0);
            string lPwd = gtpCommand.GetParameter(1);

            int lNbrGames = 1;

            if (gtpCommand.GetParameterCount() >= 3)
                if (!gtpCommand.GetParameter(2, ref lNbrGames))
                    return InvalidParameterResponse();

            if (lNbrGames <= 0)
                return InvalidParameterResponse();

            GTPCommCGOS lGTPCommCGOS = new GTPCommCGOS(gtpGoBoard.CGOSAddress, gtpGoBoard.CGOSPortNbr, lName, lPwd, lNbrGames, true);

            //			if (!lGTPCommCGOS.Connected)
            //				return new GTPInternalResponse(false, "unable to connect");

            GTPEngine lGTPEngine = new GTPEngine(gtpGoBoard, lGTPCommCGOS);

            lGTPCommCGOS.Run();

            return new GTPInternalResponse(true);
        }
Ejemplo n.º 11
0
        public static bool ExecuteTest(MemFile memFile, string directory)
        {
            GoBoard lGoBoard = new GoBoard(19);
            GTPGoBoard lGTPGoBoard = new GTPGoBoard(lGoBoard);
            GTPCommInternal lGTPCommInternal = new GTPCommInternal();
            GTPEngine lGTPEngine = new GTPEngine(lGTPGoBoard, lGTPCommInternal);

            lGTPGoBoard.Directory = directory;

            GTPCommand lGTcommand = new GTPCommand("");
            string lInput = string.Empty;

            int[] lRegressionResults = new int[5];

            while (!memFile.EOF)
            {
                string lBuffer = memFile.ReadLine('\n');

                if ((lBuffer.Length >= 4) && (lBuffer.Substring(0, 4) == "quit"))
                    break;

                if ((lBuffer.Length >= 2) && (lBuffer.Substring(0, 2) == "#?"))
                {
                    GTPRegressionPattern lPattern = new GTPRegressionPattern(lBuffer);

                    GTPRegressionResult lRegressionResult = GTPRegressionPattern.Test(lPattern, lInput);

                    lRegressionResults[(int)lRegressionResult]++;

                    switch (lRegressionResult)
                    {
                        case GTPRegressionResult.passed: /* Console.WriteLine("PASSED");*/ break;
                        case GTPRegressionResult.PASSED: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " unexpected PASS!"); break;
                        case GTPRegressionResult.failed: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " failed: Correct '" + lPattern + "', got '" + Proper(lInput) + "'"); break;
                        case GTPRegressionResult.FAILED: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " unexpected failure: Correct '" + lPattern + "', got '" + Proper(lInput) + "'"); break;
                        case GTPRegressionResult.ignore: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " ignoring '" + lPattern + "', got '" + Proper(lInput) + "'"); break;
                        default: Console.WriteLine("ERROR!!!"); break;
                    }
                }
                else
                    if (lBuffer.Length > 0)
                    {
                        GTPCommand lGTcommand2 = new GTPCommand(lBuffer);

                        if (lGTcommand2.Command.Length != 0)
                        {
                            lGTPCommInternal.SendToEngine(lBuffer);
                            lGTPCommInternal.SendToEngine("\n");

                            lInput = lGTPCommInternal.GetResponse();

                            lGTcommand = lGTcommand2;
                        }
                    }
            }

            for (int lRegressionResultIndex = 0; lRegressionResultIndex < 5; lRegressionResultIndex++)
                Console.WriteLine((GTPRegressionResult)lRegressionResultIndex + " " + lRegressionResults[lRegressionResultIndex]);

            return (lRegressionResults[3] == 0); // false, only for unexpected failures
        }
Ejemplo n.º 12
0
 public void SetGTPEngine(GTPEngine gtpEngine)
 {
     GTPEngine = gtpEngine;
 }
Ejemplo n.º 13
0
        public static bool ExecuteTest(MemFile memFile, string directory)
        {
            GoBoard         lGoBoard         = new GoBoard(19);
            GTPGoBoard      lGTPGoBoard      = new GTPGoBoard(lGoBoard);
            GTPCommInternal lGTPCommInternal = new GTPCommInternal();
            GTPEngine       lGTPEngine       = new GTPEngine(lGTPGoBoard, lGTPCommInternal);

            lGTPGoBoard.Directory = directory;

            GTPCommand lGTcommand = new GTPCommand("");
            string     lInput     = string.Empty;

            int[] lRegressionResults = new int[5];

            while (!memFile.EOF)
            {
                string lBuffer = memFile.ReadLine('\n');

                if ((lBuffer.Length >= 4) && (lBuffer.Substring(0, 4) == "quit"))
                {
                    break;
                }

                if ((lBuffer.Length >= 2) && (lBuffer.Substring(0, 2) == "#?"))
                {
                    GTPRegressionPattern lPattern = new GTPRegressionPattern(lBuffer);

                    GTPRegressionResult lRegressionResult = GTPRegressionPattern.Test(lPattern, lInput);

                    lRegressionResults[(int)lRegressionResult]++;

                    switch (lRegressionResult)
                    {
                    case GTPRegressionResult.passed: /* Console.WriteLine("PASSED");*/ break;

                    case GTPRegressionResult.PASSED: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " unexpected PASS!"); break;

                    case GTPRegressionResult.failed: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " failed: Correct '" + lPattern + "', got '" + Proper(lInput) + "'"); break;

                    case GTPRegressionResult.FAILED: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " unexpected failure: Correct '" + lPattern + "', got '" + Proper(lInput) + "'"); break;

                    case GTPRegressionResult.ignore: Console.WriteLine(lGTcommand.ToString()); Console.WriteLine(lGTcommand.CommandNbr.ToString() + " ignoring '" + lPattern + "', got '" + Proper(lInput) + "'"); break;

                    default: Console.WriteLine("ERROR!!!"); break;
                    }
                }
                else
                if (lBuffer.Length > 0)
                {
                    GTPCommand lGTcommand2 = new GTPCommand(lBuffer);

                    if (lGTcommand2.Command.Length != 0)
                    {
                        lGTPCommInternal.SendToEngine(lBuffer);
                        lGTPCommInternal.SendToEngine("\n");

                        lInput = lGTPCommInternal.GetResponse();

                        lGTcommand = lGTcommand2;
                    }
                }
            }

            for (int lRegressionResultIndex = 0; lRegressionResultIndex < 5; lRegressionResultIndex++)
            {
                Console.WriteLine((GTPRegressionResult)lRegressionResultIndex + " " + lRegressionResults[lRegressionResultIndex]);
            }


            return(lRegressionResults[3] == 0);              // false, only for unexpected failures
        }