public MoveList SimpleSearch(Color playerToMove, bool endGame) { SearchOptions lSearchOptions = GetSearchOptions(playerToMove); lSearchOptions.IncludeEndGameMoves = endGame; if (endGame) { lSearchOptions.UsePatterns = false; } Board.Dump(); Console.Error.WriteLine("Move Search: "); Console.Error.WriteLine("Max Level: " + lSearchOptions.MaxPly.ToString() + " - Max Time: " + lSearchOptions.MaxSeconds.ToString() + " Alpha: " + lSearchOptions.AlphaValue.ToString() + " Beta: " + lSearchOptions.BetaValue.ToString()); Search.Start(Board, playerToMove, lSearchOptions, SearchMethodType, null); Search.RunUntil(lSearchOptions.MaxSeconds, lSearchOptions.EarlyTimeOut); SearchStatus lSearchStatus = Search.GetStatus(); Console.Error.WriteLine("Best Move: " + Board.Coord.ToString(lSearchStatus.BestMove) + " (" + lSearchStatus.BestValue.ToString() + ")"); Console.Error.WriteLine("Nodes: " + lSearchStatus.Nodes.ToString() + " - " + (lSearchStatus.Nodes / (lSearchStatus.Timer.SecondsElapsed != 0 ? lSearchStatus.Timer.SecondsElapsed : 1)).ToString() + " per second "); Console.Error.WriteLine("Evals: " + lSearchStatus.Evals.ToString() + " - " + (lSearchStatus.Evals / (lSearchStatus.Timer.SecondsElapsed != 0 ? lSearchStatus.Timer.SecondsElapsed : 1)).ToString() + " per second"); Console.Error.WriteLine("Total: " + (lSearchStatus.Evals + lSearchStatus.Nodes).ToString() + " - " + ((lSearchStatus.Evals + lSearchStatus.Nodes) / (lSearchStatus.Timer.SecondsElapsed != 0 ? lSearchStatus.Timer.SecondsElapsed : 1)).ToString() + " per second"); Console.Error.WriteLine("TT Hits: " + lSearchStatus.TranspositionTableHits.ToString() + " - " + (lSearchStatus.TranspositionTableHits / (lSearchStatus.Timer.SecondsElapsed != 0 ? lSearchStatus.Timer.SecondsElapsed : 1)).ToString() + " per second"); Console.Error.WriteLine("Time: " + (lSearchStatus.Timer.MilliSecondsElapsed / 1000.0).ToString() + " seconds"); if ((lSearchStatus.BestMove == CoordinateSystem.PASS) && (!endGame) && (!lSearchOptions.IncludeEndGameMoves)) { Console.Error.WriteLine("End Game Search:"); return(SimpleSearch(playerToMove, true)); } if (SearchOptions.PonderOnOpponentsTime) { Search.StartPonder(lSearchStatus.BestMove, playerToMove); } else if (!SearchOptions.ContinueThinkingAfterTimeOut) { Search.RequestStop(); } MoveList lMoveList = new MoveList(Board.BoardSize); lMoveList.Add(lSearchStatus.BestMove, lSearchStatus.BestValue); return(lMoveList); }
// temp. for testing /// <summary> /// Launches the test. /// </summary> /// <returns></returns> public static int LaunchTest2() { GoBoard lGoBoard = new GoBoard(9); GameRecord lGameRecord = new GameRecord(); SGFCollection lSGFCollection = new SGFCollection(); lSGFCollection.LoadSGFFromMemory(SGFGameSamples.DYER); lSGFCollection.RetrieveGame(lGameRecord); GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, false); lGoBoard.Dump(); PatternCollection lPatternCollection = new PatternCollection(@"Patterns\test.db"); NagCoordinator lNagCoordinator = new NagCoordinator(9999, lPatternCollection); lNagCoordinator.Initialize(lGoBoard); ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999); Thread.Sleep(1000 * 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); Thread.Sleep(1000 * 300); return(0); }
// temp. for testing /// <summary> /// Launches the test. /// </summary> /// <returns></returns> public static int LaunchTest() { GoBoard lGoBoard = new GoBoard(9); GameRecord lGameRecord = new GameRecord(); SGFCollection lSGFCollection = new SGFCollection(); //lSGFCollection.LoadSGFFromMemory(SGFGameSamples.DYER); // lSGFCollection.LoadSGFFile(@"x:\CodePlex\test2.sgf"); // lSGFCollection.RetrieveGame(lGameRecord); // GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, false); lGoBoard.Dump(); PatternCollection lPatternCollection = new PatternCollection(@"Patterns\test.db"); NagCoordinator lNagCoordinator = new NagCoordinator(9999, lPatternCollection); //ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); Thread.Sleep(1000 * 14); SearchEngine lSearchEngine = new SearchEngine(lGoBoard); lSearchEngine.SetSearchMethod(SearchMethodType.AlphaBeta_NAG_ID_TT); lSearchEngine.SetNagCoordinator(lNagCoordinator); lSearchEngine.SearchOptions.MaxPly = 40; lSearchEngine.SearchOptions.MaxSeconds = 2000; lSearchEngine.SearchOptions.PatternDetector = new PatternDetector(lPatternCollection); lSearchEngine.SimpleSearch(Color.Black); Thread.Sleep(1000 * 10); return(0); }
// temp. for testing /// <summary> /// Launches the test. /// </summary> /// <returns></returns> public static int LaunchTest2() { GoBoard lGoBoard = new GoBoard(9); GameRecord lGameRecord = new GameRecord(); SGFCollection lSGFCollection = new SGFCollection(); lSGFCollection.LoadSGFFromMemory(SGFGameSamples.DYER); lSGFCollection.RetrieveGame(lGameRecord); GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, false); lGoBoard.Dump(); PatternCollection lPatternCollection = new PatternCollection(@"Patterns\test.db"); NagCoordinator lNagCoordinator = new NagCoordinator(9999, lPatternCollection); lNagCoordinator.Initialize(lGoBoard); ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); Thread.Sleep(1000 * 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1); Thread.Sleep(1000 * 300); return 0; }
// temp. for testing /// <summary> /// Launches the test. /// </summary> /// <returns></returns> public static int LaunchTest() { GoBoard lGoBoard = new GoBoard(9); GameRecord lGameRecord = new GameRecord(); SGFCollection lSGFCollection = new SGFCollection(); //lSGFCollection.LoadSGFFromMemory(SGFGameSamples.DYER); // lSGFCollection.LoadSGFFile(@"x:\CodePlex\test2.sgf"); // lSGFCollection.RetrieveGame(lGameRecord); // GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, false); lGoBoard.Dump(); PatternCollection lPatternCollection = new PatternCollection(@"Patterns\test.db"); NagCoordinator lNagCoordinator = new NagCoordinator(9999, lPatternCollection); //ThreadPoolHelperWithParam<int>.Execute(LaunchWorker, 9999); Thread.Sleep(1000 * 14); SearchEngine lSearchEngine = new SearchEngine(lGoBoard); lSearchEngine.SetSearchMethod(SearchMethodType.AlphaBeta_NAG_ID_TT); lSearchEngine.SetNagCoordinator(lNagCoordinator); lSearchEngine.SearchOptions.MaxPly = 40; lSearchEngine.SearchOptions.MaxSeconds = 2000; lSearchEngine.SearchOptions.PatternDetector = new PatternDetector(lPatternCollection); lSearchEngine.SimpleSearch(Color.Black); Thread.Sleep(1000 * 10); return 0; }
//[Test] public void Test() { GoBoard lGoBoard = new GoBoard(13); lGoBoard.PlayStone("A2", Color.Black, false); lGoBoard.PlayStone("B1", Color.Black, false); lGoBoard.PlayStone("B2", Color.Black, false); lGoBoard.PlayStone("C2", Color.Black, false); lGoBoard.PlayStone("D2", Color.Black, false); lGoBoard.PlayStone("E2", Color.Black, false); lGoBoard.PlayStone("F2", Color.Black, false); lGoBoard.PlayStone("F1", Color.Black, false); lGoBoard.PlayStone("D1", Color.Black, false); lGoBoard.PlayStone("G8", Color.Black, false); lGoBoard.PlayStone("H7", Color.Black, false); lGoBoard.PlayStone("H9", Color.Black, false); lGoBoard.PlayStone("J8", Color.Black, false); lGoBoard.PlayStone("H2", Color.Black, false); lGoBoard.PlayStone("J1", Color.Black, false); lGoBoard.PlayStone("K2", Color.Black, false); lGoBoard.Dump(); string lString = "Pattern LinkPattern4\n\n??o??\n?XoX?\n..X*.\n-----\n\n:\n\n??o??\n?Xoa?\n.*X*.\n-----\n\n;libertycount(a)>1\n\n"; Pattern lPattern = new Pattern(lString); lPattern.Dump(); PatternTest[] lPatternTests = { // new PatternTest( "1+2*3", true, true, 7, true, -1 ), // bug: right to left (instead of left to right), but okay for now new PatternTest( "", true, true, 1, false, -1 ), new PatternTest( "", true, true, true, true, -1 ), new PatternTest( "1", true, true, 1, true, -1 ), new PatternTest( "1+1", true, true, 2, true, -1 ), new PatternTest( "(1+1)", true, true, 2, true, -1 ), new PatternTest( "1>2", true, true, false, true, -1 ), new PatternTest( "(1>2)", true, true, false, true, -1 ), new PatternTest( "((1)>(1+2))", true, true, false, true, -1 ), new PatternTest( "1+2+3+4+5+6+7+8+9", true, true, 45, true, -1 ), new PatternTest( "1+2+(3+4)+5+6+7+(8+9)", true, true, 45, true, -1 ), new PatternTest( "(1+2+(3+4)+5+6+7+(8+9))", true, true, 45, true, -1 ), new PatternTest( "0&&1&&1", true, true, false, true, -1 ), new PatternTest( "1||1||0", true, true, true, true, -1 ), new PatternTest( "0&&1&&1||1", true, true, false, true, -1 ), new PatternTest( "libertycount(a)", true, true, 4, false, -1 ), new PatternTest( "libertycount(a) > 1", true, true, true, false, -1 ), new PatternTest( "1", true, true, 1, true, -1 ), new PatternTest( "1+1", true, true, 2, true, -1 ), new PatternTest( "((1)>(1+2))", true, true, false, true, -1 ), new PatternTest( " (1+2) > libertycount(a)", true, true, 0, false, -1 ), new PatternTest( " (1+2) > libertycount(a,b)", true, true, 0, false, -1 ), new PatternTest( " (1+2) > libertycount()", true, false, 0, false, -1 ), new PatternTest( " (1+2) != libertycount()+1", true, false, 0, false, -1 ), new PatternTest( " (1+2) >= libertycount()+1+2", true, false, 0, false, -1 ), new PatternTest( " (libertycount(a) == 1)", true, true, 0, false, -1 ), new PatternTest( " libertycount(a) == 1 && libertycount(b) == 1", true, true, 0, false, -1 ), new PatternTest( " (libertycount(a) == 1) || (libertycount(b) == 1)", true, true, 0, false, -1 ), new PatternTest( " ((libertycount(a) == 1) || (libertycount(b) == 1))", true, true, 0, false, -1 ), new PatternTest( "1+", true, false, 0, true, -1 ), new PatternTest( " libertycount(a) == 1)", true, false, 0, false, 100 ), new PatternTest( "libertycount(a) >" , true, false, 0, false, 101 ), new PatternTest( "(((1)>(1+2))", true, false, 0, true, -1 ), new PatternTest( "((1)>(1+2)))", true, false, 0, true, -1 ), new PatternTest( " (1+2 > libertycount(a)", true, false, 0, false, -1 ), new PatternTest( " 1+2) > libertycount(a,b)", true, false, 0, false, -1 ), new PatternTest( " libertycount(a) libertycount(b)", true, false, 0, false, -1 ), new PatternTest( " libertycount(a) == 1 libertycount(b)", true, false, 0, false, -1 ), new PatternTest( " libertycount(a) libertycount(b) == 1", true, false, 0, false, -1 ), new PatternTest(" libertycount(a) == 1 & libertycount(b) == 1", false, false, 0, false, -1 ) }; foreach (PatternTest lPatternTest in lPatternTests) { PatternCode lPatternCode = new PatternCode(); // PatternScanner lPatternScanner = new PatternScanner(lPatternTest.Expression, lPatternCode); bool lScan = !lPatternCode.IsError(); Assert.IsTrue(lScan == lPatternTest.ScanFlag, "1:" + lPatternTest.Expression); if (lScan != lPatternTest.ScanFlag) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.WriteLine("Scan : " + (lScan ? "YES" : "NO") + " Expected: " + (lPatternTest.ScanFlag ? "YES" : "NO")); } if (lScan) { PatternSyntax lPatternSyntax = new PatternSyntax(lPatternCode); bool lSyntax = lPatternSyntax.SyntaxCheck(); Assert.IsTrue(lSyntax == lPatternTest.SyntaxFlag, "2:" + lPatternTest.Expression); if (lSyntax != lPatternTest.SyntaxFlag) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.WriteLine("Syntax: " + (lSyntax ? "YES" : "NO") + " Expected: " + (lPatternTest.SyntaxFlag ? "YES" : "NO")); } if ((lSyntax) && (lPatternTest.ExecuteFlag)) { PatternInterpretor lPatternInterpretor = new PatternInterpretor(lPatternCode, lPattern); int lResult = lPatternInterpretor.Execute(lGoBoard, Color.Black, new Coordinate('K', 1), 0); Assert.IsTrue(lResult == lPatternTest.Result, "3:" + lPatternTest.Expression + " Got: " + lResult.ToString() + " Expected: " + lPatternTest.Result); Assert.IsTrue(!lPatternInterpretor.IsError(), "4:Interpretor Error: " + lPatternTest.Expression); if ((lResult != lPatternTest.Result) || (lPatternInterpretor.IsError())) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.Write("Got : " + lResult.ToString()); Console.Error.WriteLine(" Expected: " + lPatternTest.Result); } } if ((lSyntax) && (!lPatternTest.ExecuteFlag)) { PatternInterpretor lPatternInterpretor = new PatternInterpretor(lPatternCode, lPattern); int lResult = lPatternInterpretor.Execute(lGoBoard, Color.Black, new Coordinate('K', 1), 0); Assert.IsTrue(lResult == lPatternTest.Result, "5:" + lPatternTest.Expression); if ((lResult != lPatternTest.Result) || (lPatternInterpretor.IsError())) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.Write("Got : " + lResult.ToString()); Console.Error.WriteLine(" Expected: " + lPatternTest.Result); } } } } }
//[Test] public void Test() { GoBoard lGoBoard = new GoBoard(13); lGoBoard.PlayStone("A2", Color.Black, false); lGoBoard.PlayStone("B1", Color.Black, false); lGoBoard.PlayStone("B2", Color.Black, false); lGoBoard.PlayStone("C2", Color.Black, false); lGoBoard.PlayStone("D2", Color.Black, false); lGoBoard.PlayStone("E2", Color.Black, false); lGoBoard.PlayStone("F2", Color.Black, false); lGoBoard.PlayStone("F1", Color.Black, false); lGoBoard.PlayStone("D1", Color.Black, false); lGoBoard.PlayStone("G8", Color.Black, false); lGoBoard.PlayStone("H7", Color.Black, false); lGoBoard.PlayStone("H9", Color.Black, false); lGoBoard.PlayStone("J8", Color.Black, false); lGoBoard.PlayStone("H2", Color.Black, false); lGoBoard.PlayStone("J1", Color.Black, false); lGoBoard.PlayStone("K2", Color.Black, false); lGoBoard.Dump(); string lString = "Pattern LinkPattern4\n\n??o??\n?XoX?\n..X*.\n-----\n\n:\n\n??o??\n?Xoa?\n.*X*.\n-----\n\n;libertycount(a)>1\n\n"; Pattern lPattern = new Pattern(lString); lPattern.Dump(); PatternTest[] lPatternTests = { // new PatternTest( "1+2*3", true, true, 7, true, -1 ), // bug: right to left (instead of left to right), but okay for now new PatternTest("", true, true, 1, false, -1), new PatternTest("", true, true, true, true, -1), new PatternTest("1", true, true, 1, true, -1), new PatternTest("1+1", true, true, 2, true, -1), new PatternTest("(1+1)", true, true, 2, true, -1), new PatternTest("1>2", true, true, false, true, -1), new PatternTest("(1>2)", true, true, false, true, -1), new PatternTest("((1)>(1+2))", true, true, false, true, -1), new PatternTest("1+2+3+4+5+6+7+8+9", true, true, 45, true, -1), new PatternTest("1+2+(3+4)+5+6+7+(8+9)", true, true, 45, true, -1), new PatternTest("(1+2+(3+4)+5+6+7+(8+9))", true, true, 45, true, -1), new PatternTest("0&&1&&1", true, true, false, true, -1), new PatternTest("1||1||0", true, true, true, true, -1), new PatternTest("0&&1&&1||1", true, true, false, true, -1), new PatternTest("libertycount(a)", true, true, 4, false, -1), new PatternTest("libertycount(a) > 1", true, true, true, false, -1), new PatternTest("1", true, true, 1, true, -1), new PatternTest("1+1", true, true, 2, true, -1), new PatternTest("((1)>(1+2))", true, true, false, true, -1), new PatternTest(" (1+2) > libertycount(a)", true, true, 0, false, -1), new PatternTest(" (1+2) > libertycount(a,b)", true, true, 0, false, -1), new PatternTest(" (1+2) > libertycount()", true, false, 0, false, -1), new PatternTest(" (1+2) != libertycount()+1", true, false, 0, false, -1), new PatternTest(" (1+2) >= libertycount()+1+2", true, false, 0, false, -1), new PatternTest(" (libertycount(a) == 1)", true, true, 0, false, -1), new PatternTest(" libertycount(a) == 1 && libertycount(b) == 1", true, true, 0, false, -1), new PatternTest(" (libertycount(a) == 1) || (libertycount(b) == 1)", true, true, 0, false, -1), new PatternTest(" ((libertycount(a) == 1) || (libertycount(b) == 1))", true, true, 0, false, -1), new PatternTest("1+", true, false, 0, true, -1), new PatternTest(" libertycount(a) == 1)", true, false, 0, false, 100), new PatternTest("libertycount(a) >", true, false, 0, false, 101), new PatternTest("(((1)>(1+2))", true, false, 0, true, -1), new PatternTest("((1)>(1+2)))", true, false, 0, true, -1), new PatternTest(" (1+2 > libertycount(a)", true, false, 0, false, -1), new PatternTest(" 1+2) > libertycount(a,b)", true, false, 0, false, -1), new PatternTest(" libertycount(a) libertycount(b)", true, false, 0, false, -1), new PatternTest(" libertycount(a) == 1 libertycount(b)", true, false, 0, false, -1), new PatternTest(" libertycount(a) libertycount(b) == 1", true, false, 0, false, -1), new PatternTest(" libertycount(a) == 1 & libertycount(b) == 1", false, false, 0, false, -1) }; foreach (PatternTest lPatternTest in lPatternTests) { PatternCode lPatternCode = new PatternCode(); // PatternScanner lPatternScanner = new PatternScanner(lPatternTest.Expression, lPatternCode); bool lScan = !lPatternCode.IsError(); Assert.IsTrue(lScan == lPatternTest.ScanFlag, "1:" + lPatternTest.Expression); if (lScan != lPatternTest.ScanFlag) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.WriteLine("Scan : " + (lScan ? "YES" : "NO") + " Expected: " + (lPatternTest.ScanFlag ? "YES" : "NO")); } if (lScan) { PatternSyntax lPatternSyntax = new PatternSyntax(lPatternCode); bool lSyntax = lPatternSyntax.SyntaxCheck(); Assert.IsTrue(lSyntax == lPatternTest.SyntaxFlag, "2:" + lPatternTest.Expression); if (lSyntax != lPatternTest.SyntaxFlag) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.WriteLine("Syntax: " + (lSyntax ? "YES" : "NO") + " Expected: " + (lPatternTest.SyntaxFlag ? "YES" : "NO")); } if ((lSyntax) && (lPatternTest.ExecuteFlag)) { PatternInterpretor lPatternInterpretor = new PatternInterpretor(lPatternCode, lPattern); int lResult = lPatternInterpretor.Execute(lGoBoard, Color.Black, new Coordinate('K', 1), 0); Assert.IsTrue(lResult == lPatternTest.Result, "3:" + lPatternTest.Expression + " Got: " + lResult.ToString() + " Expected: " + lPatternTest.Result); Assert.IsTrue(!lPatternInterpretor.IsError(), "4:Interpretor Error: " + lPatternTest.Expression); if ((lResult != lPatternTest.Result) || (lPatternInterpretor.IsError())) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.Write("Got : " + lResult.ToString()); Console.Error.WriteLine(" Expected: " + lPatternTest.Result); } } if ((lSyntax) && (!lPatternTest.ExecuteFlag)) { PatternInterpretor lPatternInterpretor = new PatternInterpretor(lPatternCode, lPattern); int lResult = lPatternInterpretor.Execute(lGoBoard, Color.Black, new Coordinate('K', 1), 0); Assert.IsTrue(lResult == lPatternTest.Result, "5:" + lPatternTest.Expression); if ((lResult != lPatternTest.Result) || (lPatternInterpretor.IsError())) { Console.Error.WriteLine("PatternInterpretor::SelfTest (Failed)"); Console.Error.WriteLine("Failed Test: " + lPatternTest.Expression); Console.Error.Write("Got : " + lResult.ToString()); Console.Error.WriteLine(" Expected: " + lPatternTest.Result); } } } } }