Ejemplo n.º 1
0
 private static void appendInfo(StringBuilder buffer, String label, ConstPointList points) {
   appendInfoLabel(buffer, label);
   for (int i = 0; i < points.size(); ++i) {
     if (i % 10 == 9 && i < points.size() - 1) {
       buffer.append('\n');
       appendInfoLabel(buffer, "");
     }
     buffer.append(points.get(i));
     buffer.append(' ');
   }
   buffer.append('\n');
 }
Ejemplo n.º 2
0
 /**
  * Return a string containing information about a node. The string contains a listing of the data
  * stored in the node (like moves or setup stones) and properties of the node in the tree (like
  * depth or variation).
  */
 public static String nodeInfo(ConstNode node) {
   StringBuilder buffer = new StringBuilder(128);
   buffer.append("NodeProperties:\n");
   appendInfo(buffer, "Depth", getDepth(node));
   appendInfo(buffer, "Children", node.getNumberChildren());
   if (node.getMove() != null) {
     appendInfo(buffer, "Move", node.getMove().toString());
     appendInfo(buffer, "MoveNumber", getMoveNumber(node));
   }
   appendInfo(buffer, "Variation", getVariationString(node));
   ConstPointList black = node.getSetup(BLACK);
   if (black.size() > 0) appendInfo(buffer, "AddBlack", black);
   ConstPointList white = node.getSetup(WHITE);
   if (white.size() > 0) appendInfo(buffer, "AddWhite", white);
   ConstPointList empty = node.getSetup(EMPTY);
   if (empty.size() > 0) appendInfo(buffer, "AddEmpty", empty);
   if (node.getPlayer() != null) appendInfo(buffer, "Player", node.getPlayer().toString());
   if (!Double.isNaN(node.getTimeLeft(BLACK)))
     appendInfo(buffer, "TimeLeftBlack", node.getTimeLeft(BLACK));
   if (node.getMovesLeft(BLACK) >= 0)
     appendInfo(buffer, "MovesLeftBlack", node.getMovesLeft(BLACK));
   if (!Double.isNaN(node.getTimeLeft(WHITE)))
     appendInfo(buffer, "TimeLeftWhite", node.getTimeLeft(WHITE));
   if (node.getMovesLeft(WHITE) >= 0)
     appendInfo(buffer, "MovesLeftWhite", node.getMovesLeft(WHITE));
   appendInfoComment(buffer, node);
   for (MarkType type : EnumSet.allOf(MarkType.class)) {
     ConstPointList marked = node.getMarkedConst(type);
     if (marked != null && marked.size() > 0) appendInfo(buffer, "Marked " + type, marked);
   }
   Map<GoPoint, String> labels = node.getLabelsUnmodifiable();
   if (labels != null && !labels.isEmpty()) {
     StringBuilder labelsBuffer = new StringBuilder();
     boolean isFirst = true;
     for (Map.Entry<GoPoint, String> entry : labels.entrySet()) {
       if (!isFirst) labelsBuffer.append(' ');
       isFirst = false;
       GoPoint point = entry.getKey();
       String value = entry.getValue();
       labelsBuffer.append(point);
       labelsBuffer.append(':');
       labelsBuffer.append(value);
     }
     appendInfo(buffer, "Labels", labelsBuffer.toString());
   }
   if (!Float.isNaN(node.getValue())) appendInfo(buffer, "Value", Float.toString(node.getValue()));
   ConstGameInfo info = node.getGameInfoConst();
   if (info != null) {
     buffer.append("GameInfo:\n");
     for (StringInfo type : EnumSet.allOf(StringInfo.class)) {
       String s = info.get(type);
       if (s != null) appendInfo(buffer, type.toString(), s);
     }
     for (StringInfoColor type : EnumSet.allOf(StringInfoColor.class)) {
       String s = info.get(type, BLACK);
       if (s != null) appendInfo(buffer, type.toString() + "[B]", s);
       s = info.get(type, WHITE);
       if (s != null) appendInfo(buffer, type.toString() + "[W]", s);
     }
     if (info.getHandicap() != 0) appendInfo(buffer, "HANDICAP", info.getHandicap());
     if (info.getKomi() != null) appendInfo(buffer, "KOMI", info.getKomi().toString());
     if (info.getTimeSettings() != null)
       appendInfo(buffer, "TIMESETTINGS", info.getTimeSettings().toString());
   }
   ConstSgfProperties sgfProperties = node.getSgfPropertiesConst();
   if (sgfProperties != null) {
     buffer.append("SgfProperties:\n");
     for (String key : sgfProperties.getKeys()) {
       StringBuilder values = new StringBuilder();
       for (int i = 0; i < sgfProperties.getNumberValues(key); ++i) {
         values.append('[');
         values.append(sgfProperties.getValue(key, i));
         values.append(']');
       }
       appendInfo(buffer, key, values.toString());
     }
   }
   return buffer.toString();
 }