STATE
- Type which is used for states in the game.ACTION
- Type which is used for actions in the game.PLAYER
- Type which is used for players in the game.public class AlphaBetaSearch<STATE,ACTION,PLAYER> extends java.lang.Object implements AdversarialSearch<STATE,ACTION>
function ALPHA-BETA-SEARCH(state) returns an action
v = MAX-VALUE(state, -infinity, +infinity)
return the action in ACTIONS(state) with value v
function MAX-VALUE(state, alpha, beta) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v = -infinity
for each a in ACTIONS(state) do
v = MAX(v, MIN-VALUE(RESULT(s, a), alpha, beta))
if v >= beta then return v
alpha = MAX(alpha, v)
return v
function MIN-VALUE(state, alpha, beta) returns a utility value
if TERMINAL-TEST(state) then return UTILITY(state)
v = infinity
for each a in ACTIONS(state) do
v = MIN(v, MAX-VALUE(RESULT(s,a), alpha, beta))
if v <= alpha then return v
beta = MIN(beta, v)
return v
Figure 5.7 The alpha-beta search algorithm. Notice that these routines are
the same as the MINIMAX functions in Figure 5.3, except for the two lines in
each of MIN-VALUE and MAX-VALUE that maintain alpha and beta (and the
bookkeeping to pass these parameters along).Modifier and Type | Field and Description |
---|---|
static java.lang.String |
METRICS_NODES_EXPANDED |
Constructor and Description |
---|
AlphaBetaSearch(Game<STATE,ACTION,PLAYER> game) |
Modifier and Type | Method and Description |
---|---|
static <STATE,ACTION,PLAYER> |
createFor(Game<STATE,ACTION,PLAYER> game)
Creates a new search object for a given game.
|
Metrics |
getMetrics()
Returns all the metrics of the search.
|
ACTION |
makeDecision(STATE state)
Returns the action which appears to be the best at the given state.
|
double |
maxValue(STATE state,
PLAYER player,
double alpha,
double beta) |
double |
minValue(STATE state,
PLAYER player,
double alpha,
double beta) |
public static final java.lang.String METRICS_NODES_EXPANDED
public static <STATE,ACTION,PLAYER> AlphaBetaSearch<STATE,ACTION,PLAYER> createFor(Game<STATE,ACTION,PLAYER> game)
public ACTION makeDecision(STATE state)
AdversarialSearch
makeDecision
in interface AdversarialSearch<STATE,ACTION>
public Metrics getMetrics()
AdversarialSearch
getMetrics
in interface AdversarialSearch<STATE,ACTION>