Class SGFTree


  • public final class SGFTree
    extends java.lang.Object
    Contains an entire game tree. Game trees are typically read in from an SGF file, but this isn't a requirement -- they could be generated from a game that is being played.
    • Constructor Summary

      Constructors 
      Constructor Description
      SGFTree()
      Empty constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLeaf​(SGFLeaf leaf)
      Adds a leaf to the end of this tree's list of leaves.
      void addTree​(SGFTree tree)
      Appends a sub-tree to this tree's list of variations.
      int getLeafCount()
      Returns the number of leaves at this level of the game tree.
      java.util.Enumeration getLeaves()
      Returns the list of leaves at this level of the game tree.
      java.util.Enumeration getTrees()
      Returns the list of sub-trees at this level of the game tree.
      int getVariationCount()
      Returns the number of variations at this level of the game tree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SGFTree

        public SGFTree()
        Empty constructor. No leaves, no variations. Rather useless by itself.
    • Method Detail

      • addLeaf

        public void addLeaf​(SGFLeaf leaf)
        Adds a leaf to the end of this tree's list of leaves. Remember that an SGFLeaf contains moves, comments, board markup, etc.
        Parameters:
        leaf - - The leaf to add to the end of this tree's leaves list.
      • getLeaves

        public java.util.Enumeration getLeaves()
        Returns the list of leaves at this level of the game tree.
        Returns:
        A list of leaves at this variation level, or null if none.
      • getLeafCount

        public int getLeafCount()
        Returns the number of leaves at this level of the game tree. This is not the same as the total number of leaves in the game, which can only be acquired by enumerating through all the trees in the game and tallying each of their own leaf counts.

        However, most SGF files rarely show variations, and when they do they are few and far between. (This applies chiefly to professional-level games.)

        Returns:
        The number of leaves at this level of the game tree.
      • getVariationCount

        public int getVariationCount()
        Returns the number of variations at this level of the game tree. This is not the same as the total number of variations in the game.
        Returns:
        The variations at this level of the game tree.
      • addTree

        public void addTree​(SGFTree tree)
        Appends a sub-tree to this tree's list of variations.
        Parameters:
        tree - - The tree to add to the end of this tree's variation list.
      • getTrees

        public java.util.Enumeration getTrees()
        Returns the list of sub-trees at this level of the game tree.
        Returns:
        A list of sub-trees at this variation level, or null if none.