コード例 #1
0
ファイル: GTPRegression.cs プロジェクト: tgiphil/GoTraxx
        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
        }
コード例 #2
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
        }