Class DepthFirstNode<P extends IGamePosition<P>>
- Type Parameters:
P- The game position to store in this DepthFirstNode.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DepthFirstNode.RootDFNode
GameTreeNode implementation that does not store children nodes, but does store the depth of bounds and the bounds themselves.
Updates to the bounds are recorded, but the structure of the tree is not. This is particularly useful for
depth-first algorithms. As minimal information is stored, yet most GameTreeNode functionality is supported as usual.
Note that
savedChildren() will always return Optional.empty() and GameTreeNode.children(MetricKeeper...) will
always perform a node expansion.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classDepthFirstNode.RootDFNode<P extends IGamePosition<P>>An optional variant of the DepthFirstNode which stores the nodes at depth 1 in memory.Nested classes/interfaces inherited from class gametree.GameTreeNode
GameTreeNode.Result<N extends GameTreeNode<N,P>, P extends IGamePosition<P>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDepthFirstNode(DepthFirstNode<P> parent, P position, MetricKeeper... metrics) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_adjustBounds(List<DepthFirstNode<P>> children, MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.adjustBounds(List<N>, MetricKeeper...).protected List<DepthFirstNode<P>> _children(MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.children(MetricKeeper...).protected long_depthOfLower(MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.depthOfLower(MetricKeeper...).protected long_depthOfUpper(MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.depthOfUpper(MetricKeeper...).protected double_lowerbound(MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.lowerbound(MetricKeeper...).protected double_upperbound(MetricKeeper... metrics) Method to implement functionality ofGameTreeNode.upperbound(MetricKeeper...).static <P extends IGamePosition<P>>
DepthFirstNode<P> getTree(P root, boolean saveRootChildren, MetricKeeper... metrics) Get a new depth-first game tree based on the provided game position and thesaveRootChildrenparameter.booleanbooleanThis isIGamePosition.maximising()from theGameTreeNode.position()of this node.booleanreadFromTT(Table TT) Update the bounds of this node with information from a provided transposition tableAlways returns anOptional.empty()object, because this class never saves children nodes.toString()Methods inherited from class gametree.GameTreeNode
adjustBounds, adjustBounds, adjustBounds, adjustBounds, attachMetrics, CDF, children, clearPosition, combineMetricList, countSavedSubTree, depth, depthOfLower, depthOfUpper, findBest2, fromFile, getAllLeafnodes, getAttachedMetrics, getComparator, getSavedLeafnodes, hasAttachedMetrics, isRelevant, isRoot, leastPessimistic2, lowerbound, mostOptimistic2, parent, PMF, position, printTree, printTree, printTree, remainingSolveEffort, separation, separation, setParent, survivalFunction, toFile, updateMetrics, updateMetricsParental, updateTree, upperbound
-
Constructor Details
-
DepthFirstNode
-
-
Method Details
-
getTree
public static <P extends IGamePosition<P>> DepthFirstNode<P> getTree(P root, boolean saveRootChildren, MetricKeeper... metrics) Get a new depth-first game tree based on the provided game position and thesaveRootChildrenparameter. The providedMetricKeeperobjects are attached to the root of the tree and propagated to all children to record the total metrics of the search algorithm(s) utilising this tree.- Type Parameters:
P- The type of game position to store in this game tree- Parameters:
root- The root position of the game tree, this is the current position of the game that all future positions descend from.saveRootChildren-metrics-- Returns:
-
maximising
public boolean maximising()Description copied from class:GameTreeNodeThis isIGamePosition.maximising()from theGameTreeNode.position()of this node.- Specified by:
maximisingin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>- Returns:
trueif the current player-to-move is maximising the score, orfalseif it is minimising the score.
-
_children
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.children(MetricKeeper...).- Specified by:
_childrenin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
savedChildren
Always returns anOptional.empty()object, because this class never saves children nodes.- Specified by:
savedChildrenin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>- Returns:
- An Optional containing all children nodes saved in the memory of this
GameTreeNodeor an empty Optional if none are saved in memory. An Optional containing an empty List signifies a terminal node with no children.
-
_upperbound
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.upperbound(MetricKeeper...).- Specified by:
_upperboundin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
_lowerbound
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.lowerbound(MetricKeeper...).- Specified by:
_lowerboundin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
readFromTT
Update the bounds of this node with information from a provided transposition table- Parameters:
TT- The transposition table- Returns:
trueif this node's bounds were updated,falseotherwise.
-
hasSavedBounds
public boolean hasSavedBounds()- Specified by:
hasSavedBoundsin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
_adjustBounds
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.adjustBounds(List<N>, MetricKeeper...).- Specified by:
_adjustBoundsin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
_depthOfUpper
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.depthOfUpper(MetricKeeper...).- Specified by:
_depthOfUpperin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
_depthOfLower
Description copied from class:GameTreeNodeMethod to implement functionality ofGameTreeNode.depthOfLower(MetricKeeper...).- Specified by:
_depthOfLowerin classGameTreeNode<DepthFirstNode<P extends IGamePosition<P>>, P extends IGamePosition<P>>
-
toString
-