# CS 1571: Homework 3

## Search (Chapters 3 and 4): Programming Assignment (200 pts)

Assigned: September 18, 2008

Due: October 2, 2008

### Empirical Analysis of Heuristic Search

The goal of this assignment is to implement one blind search and one heuristic search algorithm for the 8-puzzle problem, then compare their performance for problem instances across several different problem sizes using a variety of statistics. The 8-puzzle problem is described in the textbook (page 65), and was also extensively discussed in class.

The uninformed search algorithm that you will implement will be Iterative Deepening Search. The informed search algorithm that you will implement will be A* using the misplaced tile heuristic (heuristic h1 on page 106, also discussed in Chapter 4.1-4.2 lecture notes). You should use treesearch (not graphsearch) algorithms.

To compare algorithm performance, your search code will need to compute the following statistics:

- the total number of nodes expanded
- the total number of nodes generated
- the maximum length of the queue structure
- the length of the solution path (number of moves)

  (1) Show that your implementation of the 8-puzzle works correctly. That is, demonstrate on an easy problem (see examples.c below) that your successor function, goal test, cost function, and heuristic function work correctly by showing pieces of a script of your code running in a verbose mode (i.e., with extra print statements). Please include enough to convince us your code for each algorithm works, and please be sure this is readable (add comments to the file to tell us what we are looking at, if it isn't obvious).

  (2) Present results of an empirical study comparing treesearch (not graphsearch) versions of iterative deepening and A* search with the misplaced tile heuristic. To do this, both algorithms should be run on multiple start states, using the following:

  - The file examples.c specifies 2 goal states, each with a few solvable initial states. They are defined in row-major form as character arrays so that you can pass them to functions and operate on them as strings. Translation to strings in a different language should be easy. Note that the last two instances are hard and might take a long time to solve. If it takes too long, you may stop the program and document this somehow in your homework.

  In particular, you should compare the two search algorithms using a format similar to Figure 4.8 in the text (p. 107). That is, for each of the 4 statistics described above, present averages over instances of the 8-puzzle as a function of solution length, for the initial and goal states in examples.c. (Note that for some or even all solution lengths, only one instance might be available, in which case you would present the result for that instance rather than the average.)

  (3) Finally, include a small writeup explaining which search you think is best and why, based on the table you constructed in part (2).