CS 4804 Homework #1
Date Assigned: Aug 30, 2006
Date Due: Sep 6, 2006, in class, before class starts
- (10 points) Problem 3.7 from your textbook (all four parts).
- (10 points) Formulate Sudoku as a search problem (if you haven't
heard about it, pick up your favorite newspaper).
Define the start state, operators, and goal states carefully. Are
all the goal states at the same level in the search tree or at
different levels? Invent a suitable heuristic for solving Sudoku.
Note: You do not have to code anything for this question. In the
next homework assignment, you will implement a full-fledged Sudoku solver.
- (10 points) Problem 3.12 from your textbook (second question only).
Readup on GRAPH-SEARCH thoroughly before attempting this problem.
- (30 points) In the "instant insanity" puzzle, you are given four
separate cubes. Each side of a cube has a single color. There are four
colors (so obviously in any given cube, one or more colors will be
repeated). The aim of the puzzle is to stack the cubes on top of one
another in a single vertical column (like a tower), such that each side
is a mix of all four colors. The colors of the other faces (hidden inside
the tower or top/bottom) does not matter. Google on "instant insanity"
for more on this puzzle.
Explain how you will model this problem as an AI search task. Specify
states, operators, and the goal test clearly. Then invent a heuristic
for solving this problem.
Note: Again, nothing to code here.
- (40 points; programming) For this question, you are going to write a
program for solving the 8-puzzle. But you should structure your code in such
a way that it can play the 15-puzzle as well. Your program must implement
A* with four heuristics - the three heuristics studied in class
- h1 = number of misplaced tiles.
- h2 = manhattan distance (i.e., sum of distances of tiles from
their goal positions).
- h3 = number of swaps with the empty board position (Gaschnig's heuristic).
and one more:
- h4 = minimum number of column adjacent blank swaps to get all
tiles in their destination column plus minimum number of row adjacent blank
swaps to get all tiles in their destination row.
Observe that h3 and h4 are a bit more involved than h1 and h2 and require some
careful algorithmic implementation.
To begin this question, notice that some 8- and 15-puzzle problems are not solvable (why?).
So even if you run your perfect heuristic on a problem that is unsolvable,
you will end up exhaustively searching the space before giving up. Therefore,
create a collection of solvable test problems to pit against your
program. This can be easily done by starting with some random tile layout,
making a sequence of moves (randomly), and choosing the resulting layout
as the goal state.
Then compare your implementations of A* search (with all the four
heuristics) and also breadth first search (BFS; with h(n) = 0).
Present results of the following form (graphs or tables):
- Number of nodes expanded by A*, for each heuristic, versus BFS, for both
problem sizes
- Effective branching factor (see textbook; Section 4.2) for A*, with
each heuristic, versus
BFS, for both problem sizes
To have confidence in your results, it is recommended that you average each
measurement over multiple problems (of a given size).
Also explain if some of the heuristics are consistently better than others.
If so, then give an ordering of the heuristics (from best to worst).