def minimax_decision(state, game):
player = game.to_move(state)<EOL>def max_value(state):<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)))<EOL><DEDENT>return v<EOL><DEDENT>def min_value(state):<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)))<EOL><DEDENT>return v<EOL><DEDENT>return argmax(game.actions(state),<EOL>lambda a: min_value(game.result(state, a)))<EOL>
Given a state in a game, calculate the best move by searching
    forward all the way to the terminal states. [Fig. 5.3]