Loading ...
Sorry, an error occurred while loading the content.
 

Re: [sgf-std] confused about http://www.red-bean.com/sgf/var.htm

Expand Messages
  • Ray Tayek
    ... yes, i was confused about the sgf tree (it is not a binary tree). ... yes, the thing that threw me was that now matter how many subtrees you were in, the
    Message 1 of 3 , Aug 27 5:46 PM
      At 10:48 PM 8/27/02 +0200, you wrote:
      > > the normal definition of pre-order is node, left (down) subtree, right
      > > (next) subtree (i am using binary trees).
      >
      >Ok, so pre-order makes (only) sense for binary trees. In SGF multi-branch
      >trees are possible. But the principle holds true. First the node, next the
      >subtrees.

      yes, i was confused about the sgf tree (it is not a binary tree).


      >Speaking in pre-oder terminology: the main line is always the left most
      >sub-tree.

      yes, the thing that threw me was that now matter how many subtrees you were
      in, the all end up being the main line down the binary tree.

      and printing in preorder does not do the right thing. you need to do it the
      way gnugo and smarto go do it. i ended up printing sgf the way they do (see
      below).

      the doc was very helpful. i was just confused :(

      thanks

      void toSgf(Indent indent,Writer writer)
      {
      try
      {
      writer.write(indent.indent()+'(');
      writer.write(toString());
      Node n=left;
      for(;n!=null&&n.right==null;n=n.left)
      writer.write(n.toString());
      indent.in();
      for(;n!=null;n=n.right)
      { writer.write(eoln);
      n.toSgf(indent,writer); }
      indent.out();
      writer.write(')');
      }
      catch(IOException e) { throw new RuntimeException(e); }
      }


      ---
      ray tayek http://home.attbi.com/~rtayek/ actively seeking telecommuting work
      vice chair orange county java users group http://www.ocjug.org/
      mailto:chair@...
      hate spam? http://samspade.org/ssw/
    Your message has been successfully submitted and would be delivered to recipients shortly.