Class BstarBasic
java.lang.Object
algorithm.BstarBasic
- All Implemented Interfaces:
SearchAlgorithm,SearchAlgorithm.SearchWithTree
This class implements B* with a few additional modifications:
- if the number of back-ups without leading back to the root reaches 1000, the algorithm is forced to back-up to the root
- if a terminal node is selected, the algorithm is forced to back-up to the root
- if the current node's best child is not its least pessimistic child, there is a 30% chance that the least pessimistic child is selected, this will not occur if this would select a terminal node
-
Nested Class Summary
Nested classes/interfaces inherited from interface algorithm.SearchAlgorithm
SearchAlgorithm.Limits, SearchAlgorithm.SearchResult<N extends GameTreeNode<N,P>, P extends IGamePosition<P>>, SearchAlgorithm.SearchWithTable, SearchAlgorithm.SearchWithTree -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBstarBasic(StopCondition extraStopCondition, StrategyFunction strategyFunction) BstarBasic(StrategyFunction strategyFunction) -
Method Summary
Modifier and TypeMethodDescriptionvoidDisable the limit on the number of rootless back-propagations made by the search.voidvoidexpectIncorrectBounds(boolean set) Correlates to theSearchTreeNode.enableIncorrectBoundsProtection(boolean)setting.<P extends IGamePosition<P>>
SearchAlgorithm.SearchResult<?, P> search(P root, Duration time_limit, SearchAlgorithm.Limits space_limit, MetricKeeper... metrics) Initiates the search of the provided game tree with a given time limit and spatial limit.<N extends GameTreeNode<N,P>, P extends IGamePosition<P>>
SearchAlgorithm.SearchResult<N, P> searchWithTree(N root, Duration time_limit, SearchAlgorithm.Limits space_limit, MetricKeeper... metrics) Initiates the search of the provided game tree with a given time limit and spatial limit.<N extends GameTreeNode<N,P>, P extends IGamePosition<P>>
NselectNext(N current, boolean provebest, MetricKeeper... metrics) voidsetFilterTerminalNodes(boolean set) voidsetMaxRootlessUpdates(long maxRootless) Sets the maximum number of rootless back-propagations made by the search until a back-propagation to the root is forced.voidsetRandomChance(double probability) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface algorithm.SearchAlgorithm
search, search, searchMethods inherited from interface algorithm.SearchAlgorithm.SearchWithTree
searchWithTree, searchWithTree, searchWithTree
-
Field Details
-
num_expanded_total
public static volatile long num_expanded_total
-
-
Constructor Details
-
BstarBasic
-
BstarBasic
-
-
Method Details
-
setMaxRootlessUpdates
public void setMaxRootlessUpdates(long maxRootless) Sets the maximum number of rootless back-propagations made by the search until a back-propagation to the root is forced. Defaults to1000.This can be disabled by calling
disableMaxRootlessUpdates()- Parameters:
maxRootless- The maximum number of rootless updates / back-propagations.
-
disableMaxRootlessUpdates
public void disableMaxRootlessUpdates()Disable the limit on the number of rootless back-propagations made by the search. This can be enabled again by callingsetMaxRootlessUpdates(long). -
setFilterTerminalNodes
public void setFilterTerminalNodes(boolean set) -
setRandomChance
public void setRandomChance(double probability) -
disableRandomChance
public void disableRandomChance() -
expectIncorrectBounds
public void expectIncorrectBounds(boolean set) Correlates to theSearchTreeNode.enableIncorrectBoundsProtection(boolean)setting. If incorrect bounds are expected, setting this totruewill keep discarded nodes in memory so they can be re-expanded again later. This defaults tofalse- Parameters:
set- the value to set to
-
search
public <P extends IGamePosition<P>> SearchAlgorithm.SearchResult<?,P> search(P root, Duration time_limit, SearchAlgorithm.Limits space_limit, MetricKeeper... metrics) Description copied from interface:SearchAlgorithmInitiates the search of the provided game tree with a given time limit and spatial limit.- Specified by:
searchin interfaceSearchAlgorithm- Type Parameters:
P- The type ofIGamePositionwhich represents the type of game to be searched- Parameters:
root- root of the tree to be searchedtime_limit- maximum time spent in the algorithmspace_limit- maximum node expansions, evaluations, and nodes saved in memory used by the algorithmmetrics- an array ofMetricKeeperobjects to keep track of evaluations, expansions, and node storage performed during the search, can be empty- Returns:
- result from the search
-
searchWithTree
public <N extends GameTreeNode<N,P>, P extends IGamePosition<P>> SearchAlgorithm.SearchResult<N,P> searchWithTree(N root, Duration time_limit, SearchAlgorithm.Limits space_limit, MetricKeeper... metrics) Description copied from interface:SearchAlgorithm.SearchWithTreeInitiates the search of the provided game tree with a given time limit and spatial limit.- Specified by:
searchWithTreein interfaceSearchAlgorithm.SearchWithTree- Type Parameters:
N- The type ofGameTreeNodewhich is used for executing the searchP- The type ofIGamePositionwhich represents the type of game to be searched- Parameters:
root- root of the tree to be searchedtime_limit- maximum time spent in the algorithmspace_limit- maximum node expansions, evaluations, and nodes saved in memory used by the algorithmmetrics- an array ofMetricKeeperobjects to keep track of evaluations, expansions, and node storage performed during the search, can be empty- Returns:
- result from the search
-
selectNext
public <N extends GameTreeNode<N,P>, P extends IGamePosition<P>> N selectNext(N current, boolean provebest, MetricKeeper... metrics)
-