def minimax_decision(state, game):
    """Given a state in a game, calculate the best move by searching
    forward all the way to the terminal states. [Fig. 5.3]"""

    player = game.to_move(state)

    def max_value(state):
        if game.terminal_test(state):
            return game.utility(state, player)
        v = -infinity
        for a in game.actions(state):
            v = max(v, min_value(game.result(state, a)))
        return v

    def min_value(state):
        if game.terminal_test(state):
            return game.utility(state, player)
        v = infinity
        for a in game.actions(state):
            v = min(v, max_value(game.result(state, a)))
        return v

    # Body of minimax_decision:
    return argmax(game.actions(state),
                  lambda a: min_value(game.result(state, a)))
def minimax_decision(state, game):
    """Given a state in a game, calculate the best move by searching
    forward all the way to the terminal states. [Fig. 5.3]"""

    player = game.to_move(state)

    def max_value(state):
        if game.terminal_test(state):
            return game.utility(state, player)
        v = -infinity
        for a in game.actions(state):
            v = max(v, min_value(game.result(state, a)))
        return v

    def min_value(state):
        if game.terminal_test(state):
            return game.utility(state, player)
        v = infinity
        for a in game.actions(state):
            v = min(v, max_value(game.result(state, a)))
        return v

    # Body of minimax_decision:
    return argmax(game.actions(state),
                  lambda a: min_value(game.result(state, a)))
def minimax_decision ( state , game ) : player = game . to_move ( state ) def max_value ( state ) : if game . terminal_test ( state ) : return game . utility ( state , player ) v = - infinity for a in game . actions ( state ) : v = max ( v , min_value ( game . result ( state , a ) ) ) return v def min_value ( state ) : if game . terminal_test ( state ) : return game . utility ( state , player ) v = infinity for a in game . actions ( state ) : v = min ( v , max_value ( game . result ( state , a ) ) ) return v # Body of minimax_decision: return argmax ( game . actions ( state ) , lambda a : min_value ( game . result ( state , a ) ) )
Given a state in a game, calculate the best move by searching
    forward all the way to the terminal states. [Fig. 5.3]
Given a state in a game calculate the best move by searching forward all the way to the terminal states . [ Fig . 5 . 3 ]