Assignment 3: Informed Search
CS 440
Fall 2015

Due: October 5, 2015 by noon MDT

Part 1: Coding [80 pts]

The purpose of this assignment is 1) to have you implement a very well known heuristic search algorithm and 2) to give you an opportunity to be creative and demonstrate your understanding of how to solve the RushHour problem.

Relation to Assignment 2

You should be able to use much of the code from assignment 2. You will need to make a few changes though:

  1. The state of the search should be represented with three elements: a board, a path and a cost. Ultimately, cost is defined as the number of moves taken to achieve the goal state from the initial state; do not include 'exit' in the count. During search, you should have other ways of defining cost (keep reading...)
  2. While moves and paths look the same as before, solutions (output) are the path, the cost of the solution and the number of explored nodes.
  3. The RushHour function should allow for 'astar' as an option for the which search argument and should take an optional last argument that is the name of a heuristic function to use. That heuristic function must also be defined somewhere in your code (keep reading...). For compatibility with the last assignment, leave in the maxLimit argument that was used in assignment 2, but do not use it in A*.
  4. The number of explored nodes will not be compared to the output of the instructor's program as there are way too many degrees of freedom in the implementation of A*. It will be used to determine how efficient is your search and to support answering some of the essay questions.
  5. Name your file rush_hour_astar.py

Informed Search Code

You need to implement one algorithm: A* search. Cost in the algorithm is cost so far plus an estimate of cost yet to go. For simplicity, we assume unit cost on all moves (i.e., each move of a vehicle for one position costs "1").

A* requires a heuristic metric to estimate the cost-yet-to-go (h) in a solution. This is where you get to exercise some creativity. You must define two heuristic functions. The heuristic functions should take a single argument: a board state. They should return an integer that estimates the cost to fill out the remainder of the solution path.

One of your heuristic functions must be called admissible and not surprisingly should be an admissible heuristic. The other must be called inadmissible and should be an inadmissible heuristic. Exactly how you compute these functions is up to you. Note: python allows functions to be passed as arguments to functions!

An example of my code running (with a pretty simple admissible heuristic) is:

>> RushHour('test3.text', 'astar', 0, admissible)
([[[0, 4], 3], [[2, 4], 0], [[2, 2], 1], [[3, 5], 3], [[0, 5], 2], [[1, 5], 2], [[5, 5], 3], [[2, 5], 2], [[2, 3], 1], ['exit']], 9, 468)
Endeavor to construct good heuristics, ones that will optimize the quality and efficiency as much as possible. Five points of your grade will be based on how well your A* performs relative to the rest of the class.

Part 2: Discussion [20 pts]

You need to write short essays (each ~1 page single spaced in 10 or 11 pt font) in answer to the following:

  1. Describe/explain your two heuristics. How do they capture knowledge about RushHour? What makes the first admissible? What makes the second inadmissible? Use examples to show them. How expensive are they to compute?
  2. Consider your solutions on test4.text and testa1.text. How does the performance change between your two heuristics? Which do you think is better? Why? Compare A* to that of BFS and IDS. How do they differ in terms of quality of solution and efficiency (you can use number of nodes expanded to measure efficiency)?

What to Hand In

  1. A python file called rush_hour_astar.py which includes all the python code needed to run your program (meaning the game specific code as well as the astar search code, but not a 'main'). You could also submit a tar file.
  2. A text file showing runs of test4.text and testa1.text with solutions for both heuristics. File should be called solution_YourName.txt
  3. A pdf file with your answers to part 2. The file should be named "essays_YourName.pdf"

Extra Credit: Recursive Best First Search [5 pts]

For extra credit, submit a version with a function RBFS which takes a game board and a heuristic function and returns a solution (same output format as in your A* implementation). Change your RushHour function so that it can take 'RBFS' as a value for the which argument (as you did with 'astar' for the required part of the assignment).