Package featurecat.lizzie.rules
Class BoardHistoryNode
java.lang.Object
featurecat.lizzie.rules.BoardHistoryNode
Node structure for the board history / sgf tree
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(BoardHistoryNode node) Sets up for a new node.If we already have a next node with the same BoardData, move to it, otherwise add it and move to it.If we already have a next node with the same BoardData, move to it, otherwise add it and move to it.childAtDepth
(int depth) Given some depth, returns the child at the given depth in the main trunk.void
clear()
Remove all subsequent nodes.boolean
compare
(BoardHistoryNode node) void
deleteChild
(int idx) int
depthOfNode
(BoardHistoryNode childNode) Given a child node, find the depth of that child node in its parentFind first move with variations in tree above node.int
findIndexOfNode
(BoardHistoryNode childNode, boolean allSub) Given a child node, find the index of that child node in its parentFinds the next node with the comment.Finds the previous node with the comment.findTop()
Find top of variation (the first move that is on the main trunk)Finds the first parent with variations.getData()
int
getDepth()
Returns the number of moves in a tree (only the left-most (trunk) variation)int
getVariation
(int idx) int
Go to the next node with the comment.int
Go to the previous node with the comment.boolean
hasDepth
(int depth) Check if there is a branch that is at least depth deep (at least depth moves)boolean
int
indexOfNode
(BoardHistoryNode childNode) Given a child node, find the index of that child node in its parentboolean
boolean
boolean
Check if node is part of the main trunk (rightmost branch)void
moveChildDown
(BoardHistoryNode child) void
moveChildUp
(BoardHistoryNode child) void
moveDown()
int
The move number of that node in its branchint
The move number of that nodevoid
moveUp()
next()
next
(boolean includeDummy) now()
int
previous()
void
resetMoveNumberList
(int start) void
resetMoveNumberListBranch
(int start) void
setFromBackChildren
(int fromBackChildren) void
void
sync
(BoardHistoryNode node)
-
Field Details
-
variations
-
-
Constructor Details
-
BoardHistoryNode
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
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
-
addOrGoto
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 onenewBranch
- add a new branch- Returns:
- the node that was just set
-
getData
- Returns:
- data stored on this node
-
getVariations
- Returns:
- variations for display
-
previous
-
next
-
next
-
isEndDummay
public boolean isEndDummay() -
topOfBranch
-
numberOfChildren
public int numberOfChildren() -
hasVariations
public boolean hasVariations() -
isFirstChild
public boolean isFirstChild() -
getVariation
-
moveUp
public void moveUp() -
moveDown
public void moveDown() -
moveChildUp
-
moveChildDown
-
swapMoveNumberList
-
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
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
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
Finds the first parent with variations.- Returns:
- the first parent with variations, if any, Optional.empty otherwise
-
findChildOfPreviousWithVariation
Find first move with variations in tree above node.- Returns:
- The child (in the current variation) of the first node with variations
-
indexOfNode
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
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
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
Finds the next node with the comment.- Returns:
- the first next node with comment, if any, Optional.empty otherwise
-
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
-
sync
-
now
-
topOfFatherBranch
-
nodeBeforeTopOfFatherBranch
-