## CS 188, Fall 2005, Introduction to Artificial Intelligence Assignment 1, due 9/20, total value 5% of grade

To be done individually. Submit online (as a1.txt or a1.pdf) or in the homework box in 283 Soda.

1. An agent is placed in an environment containing two slot machines, each of which costs \$1 to play. The expected payoffs are c and d and the agent can play each machine as many times as it likes. Describe, in qualitative terms, how a rational agent should behave in each of the following cases:
(a) The agent knows that c = 2 and d = 0.75.
(b) The agent knows that c = 2 but d is unknown.
(c) The agent knows that c = 0.995 but d is unknown.
(d) c and d are unknown.
(Hint: Remember your PEAS! Not everything is fully specified in the question; you need to fill in the missing specifications.)

2. Let us examine the rationality of various vacuum-cleaner agent functions.
(a) Show that the simple vacuum-cleaner agent function described in Figure 2.3 of AIMA2e is indeed rational under the assumptions listed on page 36.
(b) Describe a rational agent function for the modified performance measure that deducts one point for each movement. Does the corresponding agent program require internal state?
(c) Discuss possible agent designs for the cases in which clean squares can become dirty and the geography of the environment is unknown. Does it make sense for the agent to learn from its experience in these cases? If so, what should it learn?

3. For each of the following agents, develop a PEAS description of the task environment (including a characterization of the environment along the six dimensions given in lecture):
(a) Robot table-tennis player.
(b) Lisp interpreter (the program that starts when you run "alisp").
(c) Autonomous Mars rover.

4. Give the initial state, goal test, successor function, and cost function for each of the following. Choose a formulation that is precise enough to be implemented. You are not required to supply the solutions!
(a) You have to color a planar map using only three colors, with no two adjacent regions having the same color.
(b) A 3-foot-tall monkey is in a room where some bananas are suspended from the 8-foot ceiling. He would like to get the bananas. The room contains two stackable, movable, climbable 3-foot high crates.
(c) You have three jugs measuring 12 gallons, 8 gallons, and 3 gallons, and a water faucet. You need to measure out exactly one gallon.

5. Consider a state space where the start state is number 1, and the successor function for state n returns two states labelled 2n and 2n+1.
(a) Draw the portion of the state space for states 1 to 15.
(b) Suppose that the goal state is 11. List the order in which nodes will be visited for breadth-first search, depth-limited search with depth limit 3, and iterative deepening search.
(c) Can you apply best-first search to this problem? What would be a good heuristic? List the order in which nodes are visited in searching for the goal of 11 using your heuristic.
(d) Would bidirectional search be appropriate for this problem? If so, describe how it would work. What is the branching factor in each direction of the bidirectional search? Does this suggest a reformulation of the problem that would allow you to solve the problem of getting from state 1 to a given goal state with almost no search at all?

6. Consider the problem of constructing (not solving) crossword puzzles: fitting words into the white squares of a predetermined grid whose black and white squares are already fixed. Assume that a list of words (i.e., a dictionary) is provided, and that the task is to fill in the white squares using any subset of this list. Go through a complete goal and problem formulation for this domain, and choose a search strategy to solve it. Specify the heuristic function, if you think one is needed.

7. Prove that if a heuristic is consistent, it must be admissible. Construct an admissible heuristic that is not consistent.

8. A knight moves on a chessboard two squares up, down, left, or right followed by one square in one of the two directions perpendicular to the first part of the move. (I.e., the move is L-shaped.) Suppose the knight is on an unbounded board at square (0,0) and we wish to move it to square (x,y) in the smallest number of moves. (For example, to move from (0,0) to (1,1) requires two moves.)
(a) Explain how to decide whether the required number of moves is even or odd without constructing a solution.
(b) Design an admissible heuristic function for estimating the minimum number of moves required; it should be as accurate as you can make it. Prove rigorously that your heuristic is admissible.
(c) (Extra credit) Implement the problem and your heuristic using the AIMA code; measure and plot the required computation time as a function of solution length for randomly generated problem instances of increasing distance.

9. On page 108 of AIMA2e, the authors define a relaxation of the 8-puzzle in which a tile can move in one step from square A to square B if B is blank. The exact solution of this problem defines Gaschnig's heuristic (Gaschnig, 1979). Explain why Gaschnig's heuristic is at least as accurate as h1 (misplaced tiles), and show cases where it is more accurate than both h1 and h2 (Manhattan distance). Can you suggest a way to calculate Gaschnig's heuristic efficiently?

10. In this exercise, we will examine hill-climbing in the context of planar robot navigation among polygonal obstacles (as in Figure 3.22 of AIMA2e).
(a) Explain how hill-climbing would work as a method of reaching a particular point goal.
(b) Show how nonconvex obstacles can result in a local maximum for the hill-climber, using an example.
(c) Is it possible for it to get stuck with convex obstacles?
(d) Would simulated annealing always escape local maxima on this family of problems?