@@ -41,6 +41,7 @@ def alphabeta_full_search(state, game):
41
41
42
42
player = game .to_move (state )
43
43
44
+ #Functions used by alphabeta
44
45
def max_value (state , alpha , beta ):
45
46
if game .terminal_test (state ):
46
47
return game .utility (state , player )
@@ -64,16 +65,15 @@ def min_value(state, alpha, beta):
64
65
return v
65
66
66
67
# Body of alphabeta_search:
67
- return argmax (game .actions (state ),
68
- lambda a : min_value (game .result (state , a ),
69
- - infinity , infinity ))
68
+ return max_value (state , - infinity , infinity )
70
69
71
70
def alphabeta_search (state , game , d = 4 , cutoff_test = None , eval_fn = None ):
72
71
"""Search game to determine best action; use alpha-beta pruning.
73
72
This version cuts off search and uses an evaluation function."""
74
73
75
74
player = game .to_move (state )
76
75
76
+ #Functions used by alphabeta
77
77
def max_value (state , alpha , beta , depth ):
78
78
if cutoff_test (state , depth ):
79
79
return eval_fn (state )
@@ -103,9 +103,7 @@ def min_value(state, alpha, beta, depth):
103
103
cutoff_test = (cutoff_test or
104
104
(lambda state ,depth : depth > d or game .terminal_test (state )))
105
105
eval_fn = eval_fn or (lambda state : game .utility (state , player ))
106
- return argmax (game .actions (state ),
107
- lambda a : min_value (game .result (state , a ),
108
- - infinity , infinity , 0 ))
106
+ return max_value (state , - infinity , infinity , 0 )
109
107
110
108
#______________________________________________________________________________
111
109
# Players for Games
0 commit comments