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

Skip to content

Commit 869046e

Browse files
committed
Brought recursive_best_first_search closer to the pseudocode.
1 parent cf9735a commit 869046e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

search.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ def RBFS(problem, node, flimit):
229229
best = successors[0]
230230
if best.f > flimit:
231231
return None, best.f
232-
if len(successors) == 1:
233-
new_flimit = flimit
232+
if len(successors) > 1:
233+
alternative = successors[1].f
234234
else:
235-
alternative = successors[1]
236-
new_flimit = min(flimit, alternative.f)
237-
result, best.f = RBFS(problem, best, new_flimit)
235+
alternative = infinity
236+
result, best.f = RBFS(problem, best, min(flimit, alternative))
238237
if result is not None:
239238
return result, best.f
240239

0 commit comments

Comments
 (0)