public static Lazy <string> DumpDebugInfo(this MCTS <GameNode> root, int depth = 2, int indent = 0, StringBuilder result = null) { if (depth < 0) { return(new Lazy <string>(() => "")); } if (result == null) { result = new StringBuilder(); } string currentIndentStr; StringBuilder currentIndentBuilder = new StringBuilder(); for (int i = 0; i < indent; ++i) { currentIndentBuilder.Append(indentStr); } currentIndentStr = currentIndentBuilder.ToString(); result.AppendFormat("{0}move: {1}; id: {2}\n", currentIndentStr, root.Node.ParentsMove, root.ToString()); result.AppendFormat("{0}{1}score: {2}\n", currentIndentStr, indentStr, root.Node.Value); result.AppendFormat("{0}{1}expected_score: {2}\n", currentIndentStr, indentStr, root.WinRate); foreach (var child in root.Children) { child.DumpDebugInfo(depth - 1, indent + 1, result); } return(new Lazy <string>(result.ToString)); }