Ch. 4 – Informed Search Supplemental slides for CSE 327 Prof. Jeff Heflin A* Example • Use A* to solve the 8-puzzle: initial state: 1 4 7 2 6 5 3 8 goal state: 1 4 7 2 5 8 3 6 path cost is the total number of moves made • Consider these heuristics – H1: The number of tiles out of place – H2: Sum of distances of tiles from goal positions • Ignore moves that return you to the previous state A* on 8-puzzle Heuristic = H1 2 1 2 3 4 8 7 6 5 1 2 3 4 6 8 7 5 f=2+3=5 Whether or not this node is expanded depends on how you break ties. It could be expanded at any time or not at all. 1 1 2 3 4 6 8 7 5 f=0+3=3 3 f=1+3=4 1 2 3 4 6 8 7 5 f=2+4=6 1 3 f=3+3=6 4 2 6 7 5 8 4 1 2 3 4 6 7 5 8 1 2 3 4 6 7 5 8 1 2 3 4 6 7 5 8 f=2+2=4 f=3+3=6 f=1+3=4 1 2 4 6 3 7 5 8 f=2+4=6 5 1 2 3 f=3+1=4 4 5 6 7 8 1 2 3 4 5 6 7 8 f=4+2=6 6 1 2 3 f=4+0=4 4 5 6 7 8 A* on 8-puzzle 1 Heuristic = H2 1 2 3 4 6 8 7 5 1 2 3 4 6 8 7 5 f=0+4=4 2 f=1+5=6 3 1 3 4 2 6 7 5 8 f=3+3=6 1 2 3 4 6 7 5 8 f=2+2=4 1 2 3 4 6 7 5 8 f=3+3=6 1 2 3 4 6 7 5 8 f=1+3=4 1 2 4 6 3 7 5 8 f=2+4=6 4 1 2 3 f=3+1=4 4 5 6 7 8 1 2 3 4 5 6 7 8 f=4+2=6 5 1 2 3 f=4+0=4 4 5 6 7 8 Summary of Search Algorithms type ordering optimal? complete? efficient? depth-first uninformed LIFO no no if lucky breadth-first uninformed FIFO yesa yes no uniform cost uninformed g(n) yesb yesb no greedy informed h(n) no no usually A* informed g(n)+h(n) yesc yes yes a – optimal if step costs are identical b – optimal and complete if step costs > 0 c – optimal if heuristic is admissible
© Copyright 2026 Paperzz