CS 151: Artificial Intelligence
Homework 2
Due date: 9/24/13



Written questions [30 points]

Your answers to the following questions should be typed and submitted as a pdf (e.g. you can type your answers using Word and print to pdf or use LaTeX). The first question does ask you to draw a portion of a search tree so you'll need to figure out how to "draw" the tree on the computer (e.g. using shapes in Word)

  1. [15 points] AIMA 3.15 (a and b only)
  2. [5 points] AIMA 3.18
  3. [10 points] AIMA 3.23
Programming project [70 points]

This programming project will ask you to implement 4 search algorithms to help Pac-man navigate through a maze in search of food. You will implement breadth-first search, depth-first search, uniform cost search, and A-star search. You will also experiment with developing consistent heuristics for Pac-man. Since this is the first Pac-man project, set aside additional time so that you can familiarize yourself with the existing Python infrastructure. Again, you can autograde your solutions to help you catch any bugs and errors.

If you're ready, click here to begin.


Extra Credit Questions [Points awarded for the thoughtfulness, creativity, and clarity of your solutions]
  1. In class, you guys came up with a number of additional heuristics for the 8-puzzle problem. One heuristic in particular was to count the number of pairs of tiles that should be "next to each other" in the goal configuration that are, as of yet, not next to each other. Let's formalize this idea as follows:

    Step 1) Given the goal configuration, enumerate the pairs of vertically or horizontally adjacent tiles. In the picture below, the pairs of adjacent tiles in the "Goal state" are: (1,2), (3,4), (4,5), (6,7), (7,8), (3,6), (1,4), (4,7), (2,5) and (5,8) Note that the order of the tiles doesn't matter so (1,2) would be the same as (2,1). Also note that we're not listing any adjacencies that involve the blank tile.

    Step 2) Given a new configuration of the 8-puzzle, which we will denote as n, we then iterate over this list of pairs of tiles and count how many of these pairs are not adjacent in n. This gives us a sense of how much remaining work is left to reach the goal. In the example above, for the "Start state" none of the pairs of tiles are adjacent except for (5,8). In this case, our function would return 9 to indicate that 9 pairs of tiles that should be adjacent are not adjacent.

    • Question 1 Is this a heuristic? Why or why not?
    • Question 2 If it is a heuristic, is it admissable? Explain.
    • Question 3 If it is a heuristic, is it consistent? Explain.
    • Question 4 Can you say anything else about this function. For example, how does it relate to the h1 and h2 heuristics discussed in class? Does it dominate (or is it dominated by) one of these heuristics? Can you find any literature (e.g. using google scholar) regarding this possible heuristic?
  2. We had a great question in class concerning the "variability" of a heuristic. Assume we have two heuristics h1(n) and h2(n) such that neither heuristic dominates the other. That is, for some nodes n, h1(n) > h2(n), whereas for other nodes, h2(n) > h1(n).

    Let's define the "variability" of a heuristic using the standard statistical definition of variance. First, we'll define the average value of a heuristic as follows: Here S is the total number of states which we are assuming is finite. The variable h-bar is just the average value returned by the heuristic (i.e. you might think of this as the average distance to the goal). For example, if our problem has only 2 states and h1 returns [10,100] for the two states whereas h2 returns [49,50] for the two states then the average value for h1 would be (10+100)/2 = 55 and the average value for h2 would be (49+50)/2 = 49.5

    Once we have the average h-bar, we can can compute the variability of a heuristic as follows: In our example, the variance of h1 would be 2025 whereas the variance of h2 would be 0.25. (Note that both heuristics have similar means but very different variances). Intuitively, h1 returns values that vary much more than h2.

    Consider a scenario in which neither heuristic dominates the other but one heuristic does have a higher variance.

    • Question 1 In this scenario, is it always better to choose the heuristic with the higher variance (the intuition being that the higher variance heuristic is better able to distinguish between the states)? Explain your choice. Can you come up with examples or counterexamples to support your claim?


Ungraded optional problems (Solutions to these problems will be posted after the homework due date.)
  1. (Taken from http://www-nlp.stanford.edu/~grenager/cs121//handouts/hw1.pdf) Consider the popular game Sudoko in which one tries to fill a 9x9 grid of squares with numbers subject to the following constraints: every row must contain all of the digits {1...9}, every column must contain all of the digits {1...9}, and each of the 9 different 3x3 boxes must also contain all of the digits {1...9}. Some of the boxes are already filled with numbers. Here is a sample board:

    Each game is guaranteed to have a single solution. That is, there is only one assignment to the empty squares which satisfies all of the constraints. For the purposes of this homework, let n(i,j) refer to the number in row i and column j of the grid. Also, assume that M of the numbers have been specified in the starting problem (M=27 in the above picture).

    1. Formalize this problem as an incremental search problem. What are the start states, the successor function, the goal test, and the past cost function?
    2. What is the branching factor, solution depth, and maximum depth of the search space? What is the size of the state space?
    3. Which of the following would you recommend for solving the incremental search formulation of this problem: DFS, BFS, or Iterative Deepening (ID)? Why? What's the worst-case time and space complexity of your algorithm for this problem? (Provide a number for each not an algebraic expression)
  2. AIMA 3.5
  3. AIMA 3.6
  4. AIMA 3.21
  5. AIMA 3.29

Submission Instructions

You'll be turning in the "search" directory which should contain your modified search.py and searchAgents.py Python files. Add the pdf of your answers to the written questions to the "search" directory. Give the pdf an intuitive name, e.g. "hw2_written_questions.pdf". Zip (compress) the "search" directory and upload it using this URL.




Last modified: Tue Sep 10 13:34:07 PDT 2013