Details
Function iterator takes a game state as input, and outputs all valid next states.
Expression init is the unique starting configuration of the game.
Function player takes a state as input and returns the player whose turn it is. The default players are
and
.
The function
result takes a terminal game state as input and returns a value for the position. The default values are assumed to be 1 when
wins, -1 when
wins and 0 for a draw.
Function heuristic can be used to sort potential next game states:
next=
heuristic[
iterator[
state]]. Most useful heuristics will be of the form
heuristic=
Function[
SortBy[#,…]]. For statistical testing
heuristic=
RandomSample can also be useful.
Association goals links player symbols to game state values and describes how each player chooses a best next state. By default, player
chooses by
Max, and player
chooses by
Min. The form for each item of
goals is
player → 〈| "Win" →
val, "Choose" →
fun |〉, which assumes that function
fun when applied to a list of game state values will choose
val if it occurs in the list.
Default
Method "Loop" has extra cancellations, but alternative method "Recursive" is competitively performant.
Setting
PerformanceGoal to "Quality" certifies the result with a post-check of the closure conditions.
The result of ResourceFunction["AlphaBetaSearch"] is always a subgraph of ResourceFunction["FixedPointGraph"][iterator, {init}].
The result of ResourceFunction["AlphaBetaSearch"] always satisfies a closure condition as shown in Properties and Relations.
A valid result is only guaranteed for a directed acyclic iterator. If iterator finds loops in the game graph, the algorithm can not be expected to succeed.