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

Skip to content

Commit 89cba73

Browse files
committed
Break ties at random in hill_climbing.
1 parent 2f9c6f5 commit 89cba73

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ def hill_climbing(problem):
250250
neighbors = current.expand(problem)
251251
if not neighbors:
252252
break
253-
neighbor = argmax(neighbors, lambda node: problem.value(node.state))
253+
neighbor = argmax_random_tie(neighbors,
254+
lambda node: problem.value(node.state))
254255
if problem.value(neighbor.state) <= problem.value(current.state):
255256
break
256257
current = neighbor

0 commit comments

Comments
 (0)