4/19/2019 ALPHA-BETA Pseudocode function ALPHA-BETA-SEARCH( state ) returns an action inputs : state , current state in game v ← MAX -VALUE( state , - ∞, +∞) return the action in SUCCESSORS( state ) with value v CS 331: Artificial Intelligence function MAX-VALUE( state , , ) returns a utility value Alpha-Beta Practice inputs : state , current state in game , the value of the best alternative for MAX along the path to state , the value of the best alternative for MIN along the path to state if TERMINAL-TEST( state ) then return UTILITY( state ) v ← - ∞ for a , s in SUCCESSORS( state ) do v ← MAX( v , MIN-VALUE(s, , )) if v ≥ then return v ← MAX( , v) return v 2 ALPHA-BETA Pseudocode Run Alpha-Beta Pruning function MIN-VALUE( state , , ) returns a utility value MAX inputs : state , current state in game , the value of the best alternative for MAX along the path to state , the value of the best alternative for MIN along the path to state MIN if TERMINAL-TEST( state ) then return UTILITY( state ) v ← +∞ for a , s in SUCCESSORS( state ) do v ← MIN( v , MAX-VALUE(s, , )) MAX if v ≤ then return v ← MIN( , v ) return v 7 6 8 -10 2 1 -15 -10 3 4 Solution Solution MAX MAX (−∞, +∞) (−∞, +∞) MIN MIN (−∞, +∞) MAX MAX 7 6 -10 1 -15 7 6 -10 1 -15 8 2 -10 8 2 -10 5 6 1
4/19/2019 Solution Solution MAX MAX (−∞, +∞) (−∞, +∞) MIN (−∞, +∞) MIN (−∞, +∞) MAX (−∞, +∞) MAX (−∞, +∞) 7 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 7 8 Solution Solution MAX MAX (−∞, +∞) (−∞, +∞) MIN (−∞, +∞) MIN (−∞, +∞) 7 MAX (−∞, +∞) MAX (−∞, +∞) 7 7 (7, +∞) (7, +∞) 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 9 10 Solution Solution MAX MAX (−∞, +∞) (−∞, +∞) MIN (−∞, +∞) MIN (−∞, +∞) 7 7 (−∞, 7) (−∞, 7) (−∞, +∞) (−∞, +∞) (−∞, 7) MAX MAX 7 7 (7, +∞) (7, +∞) 7 6 -10 1 -15 7 6 -10 1 -15 8 2 -10 8 2 -10 11 12 2
4/19/2019 Solution Solution MAX (−∞, +∞) MAX (−∞, +∞) MIN (−∞, +∞) MIN (−∞, +∞) 7 7 (−∞, 7) (−∞, 7) MAX (−∞, +∞) (−∞, 7) MAX (−∞, +∞) (−∞, 7) 7 8 7 8 (7, +∞) (7, +∞) 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 13 14 Solution Solution (−∞, +∞) MAX (−∞, +∞) MAX 7 7 (7, +∞) MIN (−∞, +∞) MIN (−∞, +∞) 7 7 (−∞, 7) (−∞, 7) MAX (−∞, +∞) (−∞, 7) MAX (−∞, +∞) (−∞, 7) 7 8 7 8 (7, +∞) (7, +∞) 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 15 16 Solution Solution (−∞, +∞) (−∞, +∞) MAX MAX 7 7 (7, +∞) (7, +∞) A MIN (−∞, +∞) MIN (−∞, +∞) (7, +∞) 7 7 (−∞, 7) (−∞, 7) B C (−∞, +∞) (−∞, 7) (−∞, +∞) (−∞, 7) MAX MAX 7 8 7 8 (7, +∞) (7, +∞) D E F G 7 6 -10 1 -15 7 6 -10 1 -15 8 2 -10 8 2 -10 17 18 3
4/19/2019 Solution Solution (−∞, +∞) (−∞, +∞) MAX MAX 7 7 (7, +∞) (7, +∞) MIN (−∞, +∞) (7, +∞) MIN (−∞, +∞) (7, +∞) 7 7 (−∞, 7) (−∞, 7) MAX (−∞, +∞) (−∞, 7) (7, +∞) MAX (−∞, +∞) (−∞, 7) (7, +∞) 7 8 7 8 2 (7, +∞) (7, +∞) 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 19 20 Solution Solution (−∞, +∞) (−∞, +∞) MAX MAX 7 7 (7, +∞) (7, +∞) MIN (−∞, +∞) (7, +∞) MIN (−∞, +∞) (7, +∞) 7 2 7 2 (−∞, 7) (−∞, 7) MAX (−∞, +∞) (−∞, 7) (7, +∞) MAX (−∞, +∞) (−∞, 7) (7, +∞) 7 8 2 7 8 2 (7, +∞) (7, +∞) 7 6 8 -10 2 1 -15 -10 7 6 8 -10 2 1 -15 -10 21 22 4
Recommend
More recommend