File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -159,22 +159,19 @@ def depth_limited_search(problem, limit=50):
159
159
# Would this not be more elegant with an exception instead of 'cutoff'?
160
160
# Or would an exception work better for the _successful_ case? ;-)
161
161
def recursive_dls (node , problem , limit ):
162
- cutoff_occurred = False
163
162
if problem .goal_test (node .state ):
164
163
return node
165
164
elif node .depth == limit :
166
165
return 'cutoff'
167
166
else :
167
+ nonresult = None
168
168
for successor in node .expand (problem ):
169
169
result = recursive_dls (successor , problem , limit )
170
170
if result == 'cutoff' :
171
- cutoff_occurred = True
171
+ nonresult = 'cutoff'
172
172
elif result != None :
173
173
return result
174
- if cutoff_occurred :
175
- return 'cutoff'
176
- else :
177
- return None
174
+ return nonresult
178
175
# Body of depth_limited_search:
179
176
return recursive_dls (Node (problem .initial ), problem , limit )
180
177
You can’t perform that action at this time.
0 commit comments