def alphabeta_full_search(state, game):
player = game.to_move(state)<EOL>def max_value(state, alpha, beta):<EOL><INDENT>if game.terminal_test(state):<EOL><INDENT>return game.utility(state, player)<EOL><DEDENT>v = -infinity<EOL>for a in game.actions(state):<EOL><INDENT>v = max(v, min_value(game.result(state, a), alpha, beta))<EOL>if v >= beta:<EOL><INDENT>return v<EOL><DEDENT>alpha = max(alpha, v)<EOL><DEDENT>return v<EOL><DEDENT>def min_value(state, alpha, beta):<EOL><INDENT>if game.terminal_test(state):<EOL><INDENT>return game.utility(state, player)<EOL><DEDENT>v = infinity<EOL>for a in game.actions(state):<EOL><INDENT>v = min(v, max_value(game.result(state, a), alpha, beta))<EOL>if v <= alpha:<EOL><INDENT>return v<EOL><DEDENT>beta = min(beta, v)<EOL><DEDENT>return v<EOL><DEDENT>return argmax(game.actions(state),<EOL>lambda a: min_value(game.result(state, a),<EOL>-infinity, infinity))<EOL>
Search game to determine best action; use alpha-beta pruning.
    As in [Fig. 5.7], this version searches all the way to the leaves.