Upload
stuart-copeland
View
221
Download
5
Embed Size (px)
Citation preview
Chapter 6Chapter 6
Adversarial SearchAdversarial Search
Adversarial Search ProblemAdversarial Search Problem
Initial StateInitial State Successor FunctionSuccessor Function Terminal TestTerminal Test Payoff FunctionPayoff Function
Numeric value for terminal statesNumeric value for terminal states Usually Usually + for one player+ for one player
-- for the other player-- for the other player
Mini-Max AlgorithmMini-Max Algorithm
function maxValue(state)function maxValue(state)if (terminal) return value;if (terminal) return value;for s in succ(state)for s in succ(state)
maxValue = max(minValue(s), maxValue)maxValue = max(minValue(s), maxValue)
return maxValuereturn maxValue
function minValue(state)function minValue(state)if (terminal) return value;if (terminal) return value;for s in succ(state)for s in succ(state)
minValue = min(maxValue(s), minValue)minValue = min(maxValue(s), minValue)
return minValuereturn minValue
Mini-Max ExampleMini-Max Example
Mini-max AlgorithmMini-max Algorithm
Complete Depth-First SearchComplete Depth-First Search Space ComplexitySpace Complexity
O(bd)O(bd) Time ComplexityTime Complexity
O(bO(bdd))
Need Some method of pruning Need Some method of pruning the search treethe search tree
Alpha-Beta PruningAlpha-Beta Pruning
Some parts of the tree clearly do not Some parts of the tree clearly do not need to be searchedneed to be searched
Alpha-Beta PruningAlpha-Beta Pruning
alpha (alpha (αα) : ) : best choice so far for Maxbest choice so far for Max beta (beta (ββ) :) : best choice so far for Minbest choice so far for Min
alpha cut-off ifalpha cut-off if min on a branch is < alphamin on a branch is < alpha
beta cut-off ifbeta cut-off if Max on a branch is > betaMax on a branch is > beta
Alpha-Beta AlgorithmAlpha-Beta Algorithm
function maxValue(state,A,B)function maxValue(state,A,B)if (terminal) return value;if (terminal) return value;for s in succ(state)for s in succ(state)
v = max(minValue(s,A,B), v)v = max(minValue(s,A,B), v)if (v >= B) then return vif (v >= B) then return vA = max(A,v)A = max(A,v)
return vreturn v
function minValue(state,A,B)function minValue(state,A,B)if (terminal) return value;if (terminal) return value;for s in succ(state)for s in succ(state)
v = min(maxValue(s,A,B), v)v = min(maxValue(s,A,B), v)if (v <= A) then return vif (v <= A) then return vB = min(B,v)B = min(B,v)
return vreturn v
Alpha-Beta PruningAlpha-Beta Pruning
EffectivenessEffectiveness Highly dependent on which node is Highly dependent on which node is
expanded firstexpanded first However, if a good ordering can be However, if a good ordering can be
foundfound O(bO(bd/2d/2) instead of O(b) instead of O(bdd)) Effective branching factor is sqrt(b)Effective branching factor is sqrt(b)
Chess 6 vs 35Chess 6 vs 35
Imperfect Real-time decisionsImperfect Real-time decisions
Initial StateInitial State Successor FunctionSuccessor Function Terminal TestTerminal Test Payoff FunctionPayoff Function
Numeric value for terminal statesNumeric value for terminal states Usually Usually + for one player+ for one player
-- for the other player-- for the other player
Imperfect Real-time decisionsImperfect Real-time decisions
Initial StateInitial State Successor FunctionSuccessor Function Terminal TestTerminal Test Heuristic Evaluation FunctionHeuristic Evaluation Function
Numeric value for terminal statesNumeric value for terminal states Usually Usually + for one player+ for one player
-- for the other player-- for the other player
Imperfect Real-time decisionsImperfect Real-time decisions
Initial StateInitial State Successor Function Successor Function Terminal TestTerminal Test Heuristic Evaluation FunctionHeuristic Evaluation Function
Numeric value for terminal statesNumeric value for terminal states Usually Usually + for one player+ for one player
-- for the other player-- for the other player
Evaluation FunctionsEvaluation Functions Properties of a good evaluation functionProperties of a good evaluation function
AccurateAccurate FastFast
FeaturesFeatures Important aspects of the GameImportant aspects of the Game ChessChess
Material AdvantageMaterial Advantage Positional AdvantagePositional Advantage
Pawn StructurePawn Structure King SafetyKing Safety
Checkers?Checkers?
Evaluation FunctionEvaluation Function
Weighted Linear FunctionWeighted Linear Function Assumes Feature IndependenceAssumes Feature Independence