210 likes | 488 Views
State-Space Search. Computers should solve problems. A traditional problem domain for AI is the blocks world . Problem description: Given blocks A, B and C, with C on B, arrange the blocks so that A is on B and B is on C. You may only pick up and move one block at a time.
E N D
State-Space Search Computers should solve problems. A traditional problem domain for AI is the blocks world. Problem description: Given blocks A, B and C, with C on B, arrange the blocks so that A is on B and B is on C. You may only pick up and move one block at a time. A C B A B C ------------ --------------- CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
States A state consists of a complete description or snapshot of a situation arrived at during the solution of a problem. Initial state: the starting position or arrangement, prior to any problem-solving actions being taken. Goal state: the final arrangement of elements or pieces that satisfies the requirements for a solution to the problem. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
State Space The set of all possible states of the elements or components to be used in solving a problem forms the space of states for the problem. This is known as the state space. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Moves A move is a transition from one state to another. An operator is a partial function that can be applied to a state to produce a move. An operator can serve as a type of move. A sequence of moves that leads from the initial state to a goal state constitutes a solution. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
State Representation Possible methods: Board position (for a puzzle or game). List of parameter values. Set of statements in propositional calculus. Set of statements in predicate calculus. B is on the tableOntable(B) C A is on the tableOntable(A) A B C is on BOn(C, B) -------------- CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Operator Preconditions Precondition: A necessary property of a state in which a particular operator can be applied. Example: In checkers, a piece may only move into a square that is vacant. Vacant(place) is a precondition on moving a piece into place. Example: In Chess, a precondition for moving a rook from square A to square B is that all squares between A and B be vacant. (A an B must also be either in the same row or the same column.) CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
The Combinatorial Explosion Suppose a search process begins with the initial state. Then it considers each of k possible moves. Each of those may have k possible subsequent moves. In order to look n steps ahead, the number of states that must be considered is 1 + k + k2 + . . . + kn. For k > 1, this expression grows rapidly as n increase. This is known as the combinatorial explosion. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Search Trees By applying operators from a given state we generate its children or successors. Successors are descendants as are successors of descendants. If we ignore possible equivalent states among descendants, we get a tree structure. Depth-First Search: Examine the nodes of the tree by fully exploring the descendants of a node before trying any siblings of a node. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Graph Search When descendant nodes can be reached with moves via two or more paths, we are really searching a more general graph than a tree. Depth-First Search: Examine the nodes of the graph by fully exploring the “descendants” of a node before trying any “siblings” of a node. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Depth-First Search:Iterative Formulation 1. Put the start state on a list OPEN 2. If OPEN is empty, output “DONE” and stop. 3. Select the first state on OPEN and call it S. Delete S from OPEN. Put S on CLOSED. If S is a goal state, output its description 4. Generate the list L of successors of S and delete from L those states already appearing on CLOSED. 5. Delete any members of OPEN that occur on L. Insert all members of L at the front of OPEN. 6. Go to Step 2. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Breadth-First Search:Iterative Formulation 1. Put the start state on a list OPEN 2. If OPEN is empty, output “DONE” and stop. 3. Select the first state on OPEN and call it S. Delete S from OPEN. Put S on CLOSED. If S is a goal state, output its description 4. Generate the list L of successors of S and delete from L those states already appearing on CLOSED. 5. Delete any members of OPEN that occur on L. Insert all members of L at the end of OPEN. 6. Go to Step 2. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Best-First Search Similar to Depth-first and breadth-first searches. However, the list OPEN is maintained as a priority queue, with each state s on OPEN having a “heuristic value” f(s) such that the smaller f(s) is, the higher is the priority of that state for expansion. f(s) reflects an estimated “cost” of the state s. It can also be thought of as an estimate of a sort of distance between s and the nearest goal state. e.g., “longitude difference” estimates the distance between two cities. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Two-Player, Zero-Sum Games Assumptions: Two-player: (But one or both players could be computers.) Zero-sum: If one player wins, the other loses. Also, if a state is reached which is worth n points to player A, it is worth -n to player B. n + -n = 0. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction
Automatic Game-Playing Each state typically has a value (it’s so called static value.) The two players are called MIN and MAX. MIN tries to minimize the static value, while MAX tries to make it as large as possible. In many games, the state is equivalent or almost equivalent to a board position. MIN and MAX alternate turns, and each makes a move in accordance with its goals of minimizing or maximizing. The space of possible states is explored using a game tree or minimax search tree. Each level of the tree is either a MIN level or a MAX level, depending on whose move it is. CSE 415 -- (c) S. Tanimoto, 2001 Search-Introduction