Exam 1 CS 451 Wednesday, March 1, 2000 ------------------------------------------------------------------------------ Problem 1: Recall the maze problem from assignment 1. You are given a maze (a list of (x,y) coordinates), and a start and stop coordinate. The problem is to discover if you can get from the start to the stop coordinate by continually moving up, down, left or right. one space. You are only allowed to move to coordinates in the maze. Consider the sample maze ((1 2)(1 4)(2 1)(2 2)(2 3)(2 4)(2 5)(3 3) (4 1)(4 2)(4 3)(4 4)(4 5)(5 2)(5 4)), with start coordinate (3 3). I will ask some questions about search algorithms in this problem. Always assume that your search algorithm does not allow you to go back to the parent node. Additionally, when you are expanding nodes and you have a choice, assume that the algorithm prefers to expand the node with the smallest x coordinate. If the x coordinates are the same, it prefers to expand the node with the smallest y coordinate. A. Suppose that (5 4) is the stop coordinate. For each of BFS, DFS and IDS, state how many nodes will be examined. (Obviously, nodes should be counted twice if the algorithm destroys and recreates the search tree) Also, what is the largest queue size for each of the three algorithms? B. Same question where (1 2) is the stop coordinate. C. Same question where (4 3) is the stop coordinate. ------------------------------------------------------------------------------ Problem 2: Consider a different kind of maze problem. This time the maze is one-dimenasional. It is represented by a list telling you that if you are a given position, then there are two possible positions you can move to. Consider the maze: ( (1 (3 5)) (2 (3 6)) (3 (2 4)) (4 (2 3)) (5 (3 8)) (6 (7 9)) (7 (4 8)) (8 (7 10)) (9 (10 11)) (10 (5 7)) ) This says that if you are at position 1, then you can go to position 3 or 5. If you are in position 2, then you can go to position 3 or 6, etc. Starting at position 1, the object is to get to position 11. Each move has a cost of 1. So the path cost is the number of edges on that path. A. You will notice that a move can at most move you 4 spaces closer to the goal. Give an admissible heuristic based on that fact. B. Show the tree that would be constructed by the A* algorithm using the heuristic in part A. ------------------------------------------------------------------------------ Problem 3: Consider the following two person game. There are two piles of marbles. Each person on his turn chooses one pile and takes as many marbles as he wants out of that pile (but he must take at least one marble out of that pile). Suppose that you go first. The object of the game is not to take the last marble. When somebody takes the last marble, the opponent gets as many points as the number of moves in the game. For example, if I go first, then my opponent goes, and then I go again and take the last marble, then my opponent gets three points because I took the last marble and there were three moves in the game. Let (x y) represent the state with x marbles in one pile and y marbles in the other. For simplicity when you draw your tree, think of (x y) and (y x) as the same state. A. Give the minmax tree for the example when there are originally two marbles in each pile. B. Again consider the example where there are two marbles in each pile. Give the tree produced by the alpha beta pruning algorithm and explain why you pruned it wherever you pruned it. For this problem, when you have a choice of what to do next you should prefer the state that leaves the fewest total marbles. If you have a choice among two states with the same number of total marbles, choose the one whose largest pile is the smallest.