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); }
public GTPEngine(GTPGoBoard gtpGoBoard, GTPCommBase outComm) { GTPGoBoard = gtpGoBoard; Out = outComm; InputBuffer = new StringBuilder(250); outComm.SetGTPEngine(this); }
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); }
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); }
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); }
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 }