ICS 361 --Artificial Intelligence Programming

Heuristic Search and State Space Representations

Assignment #3

This assignment is worth 200 points.
1. Implement, test and compare heuristic search (A* or a variant) to the results in assignment #2 on the same problems.
• (10 p) Farmer, Wolf, Goat and Cabbage
• (10 p) Water Jugs
• (25 p) 8 puzzle
The default heuristic for all problems is the number of "items" out of place when compared to the goal state. For the N-puzzles, also implement the Manhattan distance and the number of direct tile reversals heuristics.
Use the same printing functions from Assignment #2 to show the currently expanded node at each iteration.
When a goal is reached, print the solution path (if one is found) as well as the length of the *OPEN* and *CLOSED* lists. The transcripts from these runs will be the data for your report.
2. (25 p) Implement a SOLVABLE? function for the n-puzzle to determine if a given state is solvable for a given goal. I.e. not all initial states of the N-puzzle are solvable for a specific goal state. There are two separate sets of states. All states in each set are unreachable from states in the other and vice versa.
SOLVABLE? should return T if the configuration is solvable, otherwise return NIL (meaning unsolvable).
Puzzles are solvable if there are an even number of tiles that need swapping. If an odd number is needed, the puzzle is unsolvable. This is called parity. See the papers posted on Laulima for the way to calculate the parity of an N-puzzle with respect to a specific goal.
Test your function on at least 2 unsolvable puzzles.
Discuss your solution to detecting and handling unsolvable cases in your report. Explain how you generated the new, novel puzzle instances.
3. (30 p) Create and demonstrate at least 3 new non-trivial instances of the 8 puzzle. You may use a depth limit of 35 or iterative deepening in your depth-first search on the n-puzzle. One instance must have a short, one medium and one long solution path (approx. 5, 15 and 30 states) for the least-cost/shortest/optimal solution.
For reference, see the 8-puzzle papers posted on Laulima. Use the resources provided or search for other information. Remember to cite any resources you use.
Save your output in 3OUT.txt Insert A, B, C, etc. between the assignment number and OUT if you have more than one output file. (nreed3AOUT.txt)
4. (100 p) Report - Must be written in proper English in a Scientific Style
1. (25 p) Describe your SOLVABLE? function that prevents unlimited searching for a configuration that is not solvable in the n-puzzle? Describe how this function was integrated with the main control lop
2. (50 p) Create a table using at least the following variables to compare characteristics of depth- breadth- and best- first searches. Additional variables may be included in the table as long as they are described concisely.
• b – max branching factor of the search tree
• d – depth of the least-cost solution
• m – max depth of the state-space (may be infinity)
Properties:
1. Completeness: does the method always find a solution if one exists?
2. Time complexity: how long does it take as a function of the number of nodes?
3. Space complexity: how much memory does it require?
4. Optimality: does the method guarantee the least-cost solution?
3. (25 p) Discuss the degree to which your transcripts demonstrate the complexities in your table above.
• Extra credit (50 p) Implement the 15-puzzle state space to work with your searches above. Use iterative deepening depth-first search. A solvable example follows
```11  9  4 15        1   2   3   4
1  3 -- 12        5   6   7   8
7  5  8  6        9  10  11  12
13  2 10 14       13  14  15  -- ```
Create or generate 3 new non-trivial instances of the 15 puzzle. The best solution length should be at least 5 on one, at least 10 on another, and over 15 in the third. Run all 3 searches on the new instances. Be sure to check if the instances are solvable. Comment on how the 15-puzzle examples demonstrate the time and space complexities of the searches as shown in your table.

Turn in the following on Laulima

1. One or more plain text files containing your code and output scripts.
2. Your report (in a standard format like text, rtf, or pdf). Ask our TA if you would like to use a format other than the above.

(c) N. E. Reed, 2004-2016