390 likes | 418 Views
Basic Search Procedure. 1. Start with the start node (root of the search tree) and place in on the queue 2. Remove the front node in the queue and If the node is a goal node , then we are done; stop.
E N D
Basic Search Procedure • 1. Start with the start node (root of the search tree) and place in on the queue • 2. Remove the front node in the queue and • If the node is a goal node, then we are done; stop. • Otherwise expand the node generate its children using the successor function (other states that can be reached with one move) • 3. Place the children on the queue according to the search strategy • 4. Go back to step 2.
Search Strategies • Search strategies differ based on the order in which new successor nodes are added to the queue • Breadth-first add nodes to the end of the queue • Depth-first add nodes to the front • Uniform cost sort the nodes on the queue based on the cost of reaching the node from start node
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: A
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: B I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: I E C D
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: E C D M K
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: C D M K F H
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: D M K F H N
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: M K F H N
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: K F H N O G
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: F H N O G
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: H N O G Q
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: N O G Q R T
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: O G Q R T P S
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: G Q R T P S
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S DONE!!! Solution: A I M G Queue: Q R T P S
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: A
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: B I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: C D I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: N D I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: P S D I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: S D I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: D I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: I E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: M K E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: O G K E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S Queue: G K E
Breadth-First Search A B I E C D M K F H N O G Q R T goal P S DONE!!! Solution: A I M G Queue: K E
Example: The 8-Puzzle • States? integer location of tiles • Operators? move blank left, right, up, down • Goal Test? = goal state (given) • Path Cost? One per move
Example: 8-Puzzle – Depth First Search We will assume that we can do repeated state checking (i.e., we will not generate nodes that have been previously expanded)
. . . Example: 8-Puzzle – Depth First Search