COSC 4368 (Dr. Eick) in Spring 2008
Assignment1: Heuristic Search

Final Draft

Assigned: 2/5/08
Due: problems: 3:2/14, 6a; 1,2,4,6 2/19/08 in class; Problem 5: 03/01/11p (electornic submission)

Problem 1 --- State-Space Search Representation

In the water-jug puzzle we are given a 3 liter jug, named Three, and a 4 liter jug, named Four. Initially, Three and Four are empty. A jug can be filled from a tap T, and, we can discard the water from either jug into a drain, D. Water may also be poured from one jug into another. There are no other measuring devices. We want to find a set of operations that will leave precisely two liters of water in Four.

(a) Formulate this problem as a state-space search problem Give a precise definition of a state, the start state, the goal state or goal condition, and the operators. Operators should be specified as "schemas" that indicate for a given state, when the operator is legal (i.e., a set of constraints on when the operator can be applied to an arbitrary state) and the description of the successor state after the operator is applied. In other words, each operator should be specified in a way that it would easily implemented in a program to solve this problem.

(b) Show the State Space
Draw the complete state-space graph that includes all nodes (and legal directed arcs connecting these nodes) for this problem. Inside each node show the state description, and label each arc with its associated operator. Highlight a path that gives a solution to the problem.

Problem 2 --- Using various search techniques

Assume that you have the following search graph, where S is the start node and G1 and G2 are goal nodes. Arcs are labeled with the cost of traversing them and the estimated cost to a goal is reported inside nodes.

Search Space for Problem 2 of HW1

(i) For each of the search strategies listed below, (a) indicate which goal state is reached if any, (b) list, in order, the states expanded, and (c) show the final contents of the OPEN and CLOSED lists. (Recall that a state is expanded when it is removed from the OPEN list.) When all else is equal, nodes should be expanded in alphabetical order.

  1. breadth-first
  2. depth-first
  3. best-first (using f = h)
  4. A* (using f = g + h)
  5. SMA* (using f=g+h and limiting the open-list to just 3 elements)

General Pseudocode for Searching

The following is the basic outline of the search strategy used for breadth-first, depth-first, and best-first search algorithms.

  OPEN   = { startNode } // Nodes under consideration.
  CLOSED = { }           // Nodes we're done with.

  while OPEN is not empty
  { 
    remove an item from OPEN based on search strategy used
    - call it X

    if goalState?(X) return the solution found

    otherwise // Expand node X.
    {
      1) add X to CLOSED
      2) generate the immediate neighbors (ie, children of X)
      3) eliminate those children already in OPEN or CLOSED
      4) add REMAINING children to OPEN
    }
  }
  return FAILURE  // Failed if OPEN exhausted without a goal being found.
The following is the basic outline of the search strategy used for the search algorithms.

  OPEN   = { startNode } // Nodes under consideration.
  CLOSED = { }           // Nodes we're done with.

  while OPEN is not empty
  { 
    remove an item from OPEN based on search strategy used
    - call it X

    if goalState?(X) return the solution found

    otherwise // Expand node X.
    {
      1) add X to CLOSED
      2) generate the immediate neighbors (ie, children of X)
      3) add all children to OPEN
    }
  }
  return FAILURE  // Failed if OPEN exhausted without a goal being found.

Problem 3 --- Discussion: Compare Backtracking with Best First Search

Students, whose last name starts, with A-L should present arguments why Backtracking is preferable.
Students, whose last name starts with M-Z should present arguments why Best First Search is preferable.
Mail a single Powerpoint transparency to Dr. Eick at the due date (Use your name, then blank, and then BFS or A* as message header) to ceick@aol.com. The discussion itself will take place in the class on Tu., February 19.

Problem 4: A* Termination

Algorithm A* does not terminate until a goal node is selected for expansion. However, a path to a goal node might be reached long before that node is selected for expansion. Why not terminating as soon as the goal node is found? Illustrate your answer with an example!

Problem5: Heuristic Search for a White King and Rook versus the Black King Chess Endgame

Select a search strategy, implement it, and make your algorithm "more intelligent" by using domain knowledge and "experience of past runs" for the above mentioned endgame playing the white pieces. It is assumed that white has to move first. Your objective is to capture the black king (stale mate has to be avoided). It is assumed that the fields on the chess board are represented as pairs of integers, where the first coordinate is assumed to be the x-coordinate, and the second coordinate is the y-coordinate: (1,1),(1,2),...,(8,8).

Our version of the game is deterministic in the sence that black's move is completely determined for a given position. The black king's first priority is to capture an unprotected rook. If this is not possible, it is assumed that the black king moves to a safe field (a field is safe, if it is neither in the reach of the white rook nor in the reach of the white king) for which the following value is minimal

|x-5|*5 + |y-5|*3 + (x+y)*0.1

If there is no such safe field the game ends. If the black king is attacked by the rook this is called a mate (which is a winning position for white); if the black king is not attacked attacked and cannot move this is called a stalemate (which is a draw and has to be avoided, when playing the white pieces).

Test your system for a tranining benchmark that consists of 12 example problems; the training testcases are ordered by degree of difficulty --- do not get too disappointed, if your program does not too well for some test cases with high numbers. Moreover, submit a 2 (-3) page report that describes your overall approach to solve the problem and the history of the project.

Provide an interface to your program that it can read a set of example problems from a file, and then tries to solve all problems of the set in a file. In general, your program should be able to read input-files of the following format (example: file for tranining benchmark):

number of games to play(integer)
newline
name of starting position(4 asci character)
newline
starting position (8 lines --- see example)
empty_line
newline
name of starting position(4 asci character)
newline
starting position (8 lines --- see example)
empty_line
...

Add a counter to your program that counts the number of chessboard position that are generated by your program during the search process; moreover, terminate the search after more than 10000 board positions have been generated for a single example problem. If your program succeeded in capturing the king print the sucessful state sequence (only displaying the positions with white on move) and report the number of white moves it took to capture the king, and how many board positions had to be generated in order to find the solution. Design your program so that the play of the game can be visualized on the screen and a hard-copy of the game played can be captured in a file for documentation purposes.

Problem 6: Paper Walk Through
Download Tom Mitchell's white paper on "The Discipline of Machine Learning" from: http://www.cs.cmu.edu/~tom/pubs/MachineLearning.pdf. Lead the walkthrough of the paper sections that are assigned to you. Detailed instructions on what to do will be given in the Feb. 12 class. The walkthrough itself will take place during the February 19 class.