Professional Documents
Culture Documents
Height Defined by
Evaluation
Function
current ← MAKE-NODE(INITIAL-STATE[problem])
loop do
neighbor ← a highest valued successor of current
if VALUE [neighbor] ≤ VALUE[current] then return STATE[current]
current ← neighbor
5 h=4 5 2 h=0
3 1 2 3 1 2
4 5 8 h(n) = (number of 4 5
6 7 tiles out of place) 6 7 8
5 h=3 4 h=1
3 1 2 3 1 2
4 5 h=2 4 5
6 7 8 6 7 8
4
CIS 391 - Intro to AI
8
Hill-climbing Example: n-queens
• Put n queens on an n × n board with no two
queens on the same row, column, or diagonal
a) b)
4 2
2
3 1 5
start 6 7 8 goal
4 1 2 4 1 2 1 2
3 5 3 7 5 2 3 4 5 0
6 7 8 6 8 6 7 8
1
4 1 2
3 5 2
6 7 8
CIS 391 - Intro to AI
13
The Shape of an Easy Problem
• Random restart
• Problem reformulation
current ← MAKE-NODE(INITIAL-STATE[problem])
for t ← 1 to ∞ do
T ← schedule[t]
if T = 0 then return current
next ← a randomly selected successor of current
∆E ← VALUE[next] - VALUE[current]
if ∆E > 0 then current ← next
else current ← next only with probability e∆E /T