Package com.barrybecker4.ca.dj.jigo.sgf
Class SGFTree
- java.lang.Object
-
- com.barrybecker4.ca.dj.jigo.sgf.SGFTree
-
public final class SGFTree extends java.lang.ObjectContains 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 voidaddLeaf(SGFLeaf leaf)Adds a leaf to the end of this tree's list of leaves.voidaddTree(SGFTree tree)Appends a sub-tree to this tree's list of variations.intgetLeafCount()Returns the number of leaves at this level of the game tree.java.util.EnumerationgetLeaves()Returns the list of leaves at this level of the game tree.java.util.EnumerationgetTrees()Returns the list of sub-trees at this level of the game tree.intgetVariationCount()Returns the number of variations at this level of the game tree.
-
-
-
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.
-
-