public static List <SGFTree> Load(StreamReader reader) { List <SGFTree> list = new List <SGFTree>(); bool lineStart = true; int c; while (true) { SGFTree tree = new SGFTree(new TreeNode(1)); while (true) { try { c = tree.ReadChar(reader); } catch (System.Exception ex) { goto goon; } if (lineStart && c == '(') { break; } if (c == '\n') { lineStart = true; } else { lineStart = false; } } tree.ReadNodes(tree.root, reader); list.Add(tree); } goon: return(list); }
public static void ExportToSgf(string filePath, TreeNode root) { string res = SGFTree.GetSgfString(root); SGFTree.Save(filePath, res); }