Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3fb5563

Browse files
committed
Restored recursive_dls() to following Fig. 3.17.
1 parent fed270f commit 3fb5563

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

search.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,15 @@ def recursive_dls(node, problem, limit):
164164
elif node.depth == limit:
165165
return 'cutoff'
166166
else:
167-
nonresult = None
167+
cutoff_occurred = False
168168
for successor in node.expand(problem):
169169
result = recursive_dls(successor, problem, limit)
170170
if result == 'cutoff':
171-
nonresult = 'cutoff'
171+
cutoff_occurred = True
172172
elif result != None:
173173
return result
174-
return nonresult
174+
return if_(cutoff_occurred, 'cutoff', None)
175+
175176
# Body of depth_limited_search:
176177
return recursive_dls(Node(problem.initial), problem, limit)
177178

0 commit comments

Comments
 (0)