CS 331 Assignment #1: Uninformed and Informed Search
Out: April 6, 2012
Due: April 18, 2012 at 17:00:00
Type: Team Assignment (Groups of 2 max)
Description
The 8-puzzle consists of numbered tiles (1 through 8) and a special blank tile on a 3x3 grid. You can slide any tile adjacent to the
blank tile into the blank tile's spot. The goal of the 8-puzzle is to reach the goal state from the start state. The figure below
gives an example of the start state and the goal state. Note that you may not be able to get to the goal state with some start states.
In this assignment, you will write code to solve the 8-puzzle. The algorithms you will implement are breadth-first search,
depth-first search, iterative deepening depth-first search and A-star search for a sliding tile 8-puzzle. Your code will print out the
solution path from the start state to the goal state or a no solution found message if no such path exists. Your code will also print
out the number of search nodes expanded.
Tile Puzzle File Format
The file format for the tile puzzle state is simply a set of comma-separated numbers arranged as they are in the tile puzzle.
For example, the tile puzzle state
1 2 3
4 5 6
7 9
is represented in a text file as:
1,2,3
4,5,6
7,0,9
We use the number 0 to denote the blank space in the tile puzzle state. This decision was due to problems with parsing blank spaces. Your program will take as input a starting state file and a goal state file. Your code must be able to read the start and goal state files. We will only be marking your code on 3x3 puzzles.
Requirements
You may the following programming languages: Java, C, C++. If you use any other programming language, it must be available on the ENGR
systems and you must contact the Teaching Assistant for approval.
Your code should take the following command line arguments:
< initial puzzle state file > < goal puzzle state file > < mode > < output file >
The mode argument is either:
- bfs (for breadth-first search)
- dfs (for depth-first search)
- iddfs (for iterative deepening depth-first search)
- astar (for A-Star search below)
I. Uninformed Search
You will implement Breadth-First Search, Depth-First Search and Iterative-Deepening Depth First Search. Use the pseudocode for the
GraphSearch function and the Expand function in either my slides or the textbook to help you design the algorithm. If you don't follow
the GraphSearch and Expand pseudocode, your algorithms may not work properly.
There are specific requirements regarding the uniformed search algorithms that you must follow in this assignment:
- When generating successors for a state, do so in the order of moving the blank space up, right, down, and left.
As an example, suppose we are at:
1 2 3
4 0 5
6 7 8
The successors (in order) are:
1 0 3 1 2 3 1 2 3 1 2 3
4 2 5 4 5 0 4 7 5 0 4 5
6 7 8 6 7 8 6 0 8 6 7 8
- You will need a counter for the number of nodes expanded. Update this counter after you remove the node from the fringe and just
before you call the expand function (note that if it is a goal node, you don't need to expand it and hence don't count the goal node as an
expanded node). At the end of the graph search, print out the number of nodes that were expanded.
- You need to print the solution path which shows how to move the tiles from the start state to the goal state. Please print this to
the screen and to an output file. Make sure it is in the right order!
II. Informed Search
In this part, you will implement A-star search. As with uninformed search, there are specific requirements that you must follow:
- When generating successors for a state, do it in the order of moving the blank space up, right, down, left. This is identical
to the order used for the Uninformed Search algorithms above.
- Keep track of the number of nodes expanded in the same way as specified for the Uninformed Search above.
- You will need a priority queue. You may use built-in code from your programming language (eg. Java) for the priority queue.
- You will need a heuristic for A-star search. Pick one but make sure it is admissible.
- You need to print the solution path which shows how to move the tiles from the start state to the goal state. Please print this to
the screen and to an output file. Make sure it is in the right order!
Test Files
There are three test cases that you should run your algorithm on. These tests and the corresponding files are:
- Test1: testStart1.txt, testGoal1.txt
- Test2: testStart2.txt, testGoal2.txt
- Test3: testStart3.txt, testGoal3.txt
Record how many nodes were on the solution path and how many nodes were expanded for each of BFS, DFS, ID-DFS and A-Star Search.
You will need to set a max depth for ID-DFS. Try to make the max depth as large as possible.
The Assignment Report
Your assignment report should be about 1-2 pages and should not exceed 2 pages. I accept pdf or doc files (pdf is preferred).
For your report, you will do the following sections:
- Methodology: Describe the experiments you ran on the three test cases. Make sure you specify all parameters that you used for
the search algorithms (eg. the depth limit in DFS, heuristic for A-star search). You can assume the reader is familiar with search
algorithms and you don't need to describe how the search algorithms operate. However, the description should be complete enough that
someone else can reimplement these search algorithms on their own and re-run the exact same set of experiments using the parameters
you used. Make sure you explain why you chose the heuristic for A-star search.
- Results: Summarize your results for the three test cases in terms of the # of nodes on the solution path and # of nodes
expanded on each test graph for each of the search techniques. Use either a table or a graph to illustrate the results.
- Discussion: Discuss your results. Are they as expected? Was there any interesting behavior that you found?
- Conclusion: Add a conclusion which answers the following questions: What can you conclude from these results? Which
search algorithm performs the best? Was this expected?
Hints
- You will need a closed list to keep track of the states that you have already visited. Use a hash table for this.
- If you are using Java and running out of memory, add the -mx1024M flag to the Java Virtual Machine (this is done through Eclipse.
See me if you don't know how to do this).
Hand in
Please hand in all of your source code and your report. Also include a text file called team.txt which lists the names of
the members of your team. Zip everything up with a zip program. To hand in your assignment, go to the
TEACH electronic handin site: https://secure.engr.oregonstate.edu:8000/
- Login to the TEACH system
- Click on the "Submit Assignment" link on the left hand side
- Select ProgrammingAssn1 from the dropdown menu, hit submit query
- For redundancy, leave a web comment stating who your team members are. If I don't know who is on your assignment team, they won't get credit.
- Enter the path of your zip file. Hit Submit Query to hand everything in.
Grading Criteria
The assignment is out of 50. Note that the bulk of the marks are allocated to your report. The code is intended to help you
produce results for the experiments. We will run the code to make sure it works.
- Report (30 points):
- Methodology (5 points)
- Results (10 points)
- Discussion (10 points)
- Conclusion (5 points)
- Code (20 points)