The object representing the state of the game
The object representing a move in the game
Extra data used in evaluation not suitable for storing in the gamestate
Root node to start the tree from
Optional options to configure the minimax algorithm
Protected
evalThe result of the search
Overide the depth property in depth
Protected
minimaxImplements the minimax algorithm up to a given depth of search.
Recursively calls itself until depth
is 0
or LEAF
node is reached and evaluated.
Node values and best child are chosen according to the NodeAim of the parent nodes.
Returns early if timeout occurs
Reason for returning.
Node to evaluate or search children
Depth to search from this node
minimum guaranteed score
maximum guaranteed score from minimising player
Protected
minimumGoes through all of nodes children to find child with minimum inherited value
Protected
maximumGoes through all of nodes children to find child with minimum inherited value
Protected
alphaFind the best child of a node using alpha beta pruning
Reason for exit and opional best child
Node to find best child of
Depth to limit search to
Current alpha value
current beta value
Protected
assignreason for exit. Either FULL_DEPTH or DEPTH.
Node to assign value to
true
if node is a leaf
Protected
evalSearches the tree repeatedly, incrementing the depth each time. Returns after reaching target depth, or early if tree is complete or time exceeded.
The result of the search
Search the tree according to the options specified by the options (opts).
Result from the tree search
Called during deepening search between each depth. Does nothing until overidden
Protected
checkProtected
checkProtected
getReturns either the array of node children or a generator which may create children on the fly Also presorts children if enabled
An iterable for going through children of node
Node to return an iterable of children
Protected
sortSorts the child nodes of given parent Node according to inherited value. Sort is descending by default
Sorts using the method specififed in opts.SearchOpts.SortMethod.
The child with the highest value
Protected
randomSelects from the nodes children which all have an equal best value (and depth) Uniform random weighting Node.child must already represent best child
randomly selected best child with same value as best
Parent to select best child from
Protected
randomProtected
routeProtected
optimalFunction to return the list of moves starting from the root that are the 'optimal' path.
Must be called after evaluating the tree.
A list of moves from the active root Node that represent the optimal sequence through the game.
Protected
removeProtected
createProtected
createCreates the full game tree starting from activeRoot.
Uses the GetMoves and CreateChildNode callbacks.
Protected
childProtected
expiredTracks whether a searched has expired due to time
Protected
expireTime the search will expire. 0 disables expiry
Protected
fullFlags that full depth has not been reached when set to false
Protected
presortEnables presort of children internally
Protected
outcomesNumber of leaf or depth = 0 reached during current call
Protected
nodeFlag set if node limit has been reached
Callback to evaluate the value of gamestate attached to node
Original root when tree was created
Active root used for the creation and searching of tree. Set to root in constructor.
Number of nodes in tree
Number of leaf nodes in tree
Protected
activeMaximum depth of current search
Callback to get the moves for a gamestate attached to a Node.
Callback to create a child of a parent node using a move
Generated using TypeDoc
Class for performing a minimax search.
Probability based searches coming soon
Usage
See the Negamax documentation for general usage, its is very similar.
The differences are as follows: