## CS 343 Artificial Intelligence Homework 1: Search

Due: Wednesday, Sept. 15, 2010

8-puzzle is a board game with tiles numbered 1 through 8 located on a 3x3 grid, leaving one space blank. Tiles adjacent to the blank space can be slid into it vertically or horizontally. The goal of the game is to reach the following board position:

 1 2 3 8 4 7 6 5

Each state in the state space corresponds to a particular position on the board. There are four operators, corresponding to the blank space moving up(U), left(L), down(D) or right(R). For questions 1 and 2, start from the following board position:

 1 3 4 8 2 7 6 5

Let the operators be evaluated in the following order:
i. D
ii. U
iii. L
iv. R

When you draw your search trees, draw the board configuration at each node to represent the state at that node. Note that expanded is different from generated; expansion occurs when a node's successors are generated. Also remember that you don't need to generate states that have already been generated, i.e. assume all repeated states are detected and removed. Except for A* (question 4), you can assume that a goal state is detected (and the search terminated) the instant the goal state is generated. You do not need to wait until it is eventually expanded to notice that it is a goal. For A* (and uniform cost), to ensure optimality, it is important NOT to stop when a goal is generated but to wait until it is actually chosen for expansion. This is to avoid the situation where a goal is first generated via a non-optimal path.

1. Draw the search tree resulting from breadth-first search. Label the nodes in the order in which they are expanded.
2. Draw the search tree resulting from depth-first search with a depth limit of four (that is the maximum length of a path in a tree is four). Label the nodes in the order in which they are expanded. What are the advantages and disadvantages of breadth-first and limited depth-first search for this problem? Would depth-first search with no limit be a better or worse approach? Why?

For questions 3, 4, and 5, start from the following board position:

 1 2 3 6 4 8 7 5

Let the operators be evaluated in the following order:
i. U
ii. D
iii. L
iv. R

1. Consider a heuristic function h = number of tiles that are not in the correct place. Draw the search tree resulting from best-first search using this heuristic function. Assume that ties are broken in favor of a position that is deeper in the tree. After this, break the tie in favor of the node that was generated first. Label the nodes in the order in which they are expanded. Also, mark the h value of each node.
2. Draw the search tree resulting from using A*, where g is the number of operators executed and h is the heuristic function above. Label the nodes in the order in which they are expanded. Also, mark the f=g+h value of each node (just mark f, not g or h).
3. Consider a heuristic function h1 = number of tiles that are not in the correct row plus number of tiles that are not in the correct column. Draw the search tree resulting from best-first search using this heuristic function, labeling the nodes in the order in which they are expanded and with their h1 value. Is this heuristic admissable? Why or why not? Is it better than heuristic h above?