Class BoardHistoryNode


  • public class BoardHistoryNode
    extends Object
    Node structure for the board history / sgf tree
    • Constructor Detail

      • BoardHistoryNode

        public BoardHistoryNode​(BoardData data)
        Initializes a new list node
    • Method Detail

      • clear

        public void clear()
        Remove all subsequent nodes.
      • add

        public BoardHistoryNode add​(BoardHistoryNode node)
        Sets up for a new node. Overwrites future history.
        Parameters:
        node - the node following this one
        Returns:
        the node that was just set
      • addOrGoto

        public BoardHistoryNode addOrGoto​(BoardData data)
        If we already have a next node with the same BoardData, move to it, otherwise add it and move to it.
        Parameters:
        data - the node following this one
        Returns:
        the node that was just set
      • addOrGoto

        public BoardHistoryNode addOrGoto​(BoardData data,
                                          boolean newBranch)
        If we already have a next node with the same BoardData, move to it, otherwise add it and move to it.
        Parameters:
        data - the node following this one
        newBranch - add a new branch
        Returns:
        the node that was just set
      • getData

        public BoardData getData()
        Returns:
        data stored on this node
      • numberOfChildren

        public int numberOfChildren()
      • hasVariations

        public boolean hasVariations()
      • isFirstChild

        public boolean isFirstChild()
      • moveUp

        public void moveUp()
      • moveDown

        public void moveDown()
      • swapMoveNumberList

        public void swapMoveNumberList​(BoardHistoryNode child)
      • resetMoveNumberListBranch

        public void resetMoveNumberListBranch​(int start)
      • resetMoveNumberList

        public void resetMoveNumberList​(int start)
      • deleteChild

        public void deleteChild​(int idx)
      • setFromBackChildren

        public void setFromBackChildren​(int fromBackChildren)
        Parameters:
        fromBackChildren - the fromBackChildren to set
      • getFromBackChildren

        public int getFromBackChildren()
        Returns:
        the fromBackChildren
      • getDepth

        public int getDepth()
        Returns the number of moves in a tree (only the left-most (trunk) variation)
        Returns:
        number of moves in a tree
      • childAtDepth

        public BoardHistoryNode childAtDepth​(int depth)
        Given some depth, returns the child at the given depth in the main trunk. If the main variation is too short, silently stops early.
        Returns:
        the child at the given depth
      • hasDepth

        public boolean hasDepth​(int depth)
        Check if there is a branch that is at least depth deep (at least depth moves)
        Returns:
        true if it is deep enough, false otherwise
      • findTop

        public BoardHistoryNode findTop()
        Find top of variation (the first move that is on the main trunk)
        Returns:
        top of variation, if on main trunk, return start move
      • firstParentWithVariations

        public Optional<BoardHistoryNode> firstParentWithVariations()
        Finds the first parent with variations.
        Returns:
        the first parent with variations, if any, Optional.empty otherwise
      • findChildOfPreviousWithVariation

        public Optional<BoardHistoryNode> findChildOfPreviousWithVariation()
        Find first move with variations in tree above node.
        Returns:
        The child (in the current variation) of the first node with variations
      • indexOfNode

        public int indexOfNode​(BoardHistoryNode childNode)
        Given a child node, find the index of that child node in its parent
        Returns:
        index of child node, -1 if child node not a child of parent
      • findIndexOfNode

        public int findIndexOfNode​(BoardHistoryNode childNode,
                                   boolean allSub)
        Given a child node, find the index of that child node in its parent
        Returns:
        index of child node, -1 if child node not a child of parent
      • depthOfNode

        public int depthOfNode​(BoardHistoryNode childNode)
        Given a child node, find the depth of that child node in its parent
        Returns:
        depth of child node, 0 if child node not a child of parent
      • moveNumberInBranch

        public int moveNumberInBranch()
        The move number of that node in its branch
        Returns:
        move number of node, 0 if node not a child of branch
      • moveNumberOfNode

        public int moveNumberOfNode()
        The move number of that node
        Returns:
        move number of node
      • isMainTrunk

        public boolean isMainTrunk()
        Check if node is part of the main trunk (rightmost branch)
        Returns:
        true if node is part of main trunk, false otherwise
      • goToNextNodeWithComment

        public int goToNextNodeWithComment()
        Go to the next node with the comment.
        Returns:
        the move count to the next node with comment, 0 otherwise
      • goToPreviousNodeWithComment

        public int goToPreviousNodeWithComment()
        Go to the previous node with the comment.
        Returns:
        the move count to the previous node with comment, 0 otherwise