Class BoardHistoryNode

java.lang.Object
featurecat.lizzie.rules.BoardHistoryNode

public class BoardHistoryNode extends Object
Node structure for the board history / sgf tree
  • Field Details

  • Constructor Details

    • BoardHistoryNode

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

    • clear

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

      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)
    • addOrGoto

      public BoardHistoryNode addOrGoto(BoardData data, boolean newBranch, boolean changeMove)
      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
    • getVariations

      public List<BoardHistoryNode> getVariations()
      Returns:
      variations for display
    • previous

      public Optional<BoardHistoryNode> previous()
    • next

      public Optional<BoardHistoryNode> next()
    • next

      public Optional<BoardHistoryNode> next(boolean includeDummy)
    • isEndDummay

      public boolean isEndDummay()
    • topOfBranch

      public BoardHistoryNode topOfBranch()
    • numberOfChildren

      public int numberOfChildren()
    • hasVariations

      public boolean hasVariations()
    • isFirstChild

      public boolean isFirstChild()
    • getVariation

      public Optional<BoardHistoryNode> getVariation(int idx)
    • moveUp

      public void moveUp()
    • moveDown

      public void moveDown()
    • moveChildUp

      public void moveChildUp(BoardHistoryNode child)
    • moveChildDown

      public void moveChildDown(BoardHistoryNode child)
    • 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
    • findNextNodeWithComment

      public Optional<BoardHistoryNode> findNextNodeWithComment()
      Finds the next node with the comment.
      Returns:
      the first next node with comment, if any, Optional.empty otherwise
    • findPreviousNodeWithComment

      public Optional<BoardHistoryNode> findPreviousNodeWithComment()
      Finds the previous node with the comment.
      Returns:
      the first previous node with comment, if any, Optional.empty 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
    • compare

      public boolean compare(BoardHistoryNode node)
    • sync

      public void sync(BoardHistoryNode node)
    • now

      public Optional<BoardHistoryNode> now()
    • topOfFatherBranch

      public BoardHistoryNode topOfFatherBranch()
    • nodeBeforeTopOfFatherBranch

      public BoardHistoryNode nodeBeforeTopOfFatherBranch()