def depth_limited_search(problem, limit=50):
    "[Fig. 3.17]"
    def recursive_dls(node, problem, limit):
        if problem.goal_test(node.state):
            return node
        elif node.depth == limit:
            return 'cutoff'
        else:
            cutoff_occurred = False
            for child in node.expand(problem):
                result = recursive_dls(child, problem, limit)
                if result == 'cutoff':
                    cutoff_occurred = True
                elif result is not None:
                    return result
            return if_(cutoff_occurred, 'cutoff', None)

    # Body of depth_limited_search:
    return recursive_dls(Node(problem.initial), problem, limit)
def depth_limited_search(problem, limit=50):
    "[Fig. 3.17]"
    def recursive_dls(node, problem, limit):
        if problem.goal_test(node.state):
            return node
        elif node.depth == limit:
            return 'cutoff'
        else:
            cutoff_occurred = False
            for child in node.expand(problem):
                result = recursive_dls(child, problem, limit)
                if result == 'cutoff':
                    cutoff_occurred = True
                elif result is not None:
                    return result
            return if_(cutoff_occurred, 'cutoff', None)

    # Body of depth_limited_search:
    return recursive_dls(Node(problem.initial), problem, limit)
def depth_limited_search ( problem , limit = 50 ) : def recursive_dls ( node , problem , limit ) : if problem . goal_test ( node . state ) : return node elif node . depth == limit : return 'cutoff' else : cutoff_occurred = False for child in node . expand ( problem ) : result = recursive_dls ( child , problem , limit ) if result == 'cutoff' : cutoff_occurred = True elif result is not None : return result return if_ ( cutoff_occurred , 'cutoff' , None ) # Body of depth_limited_search: return recursive_dls ( Node ( problem . initial ) , problem , limit )
[Fig. 3.17]
[ Fig . 3 . 17 ]