Exam 1 CS 451 Tuesday, March 2, 1999 For each of these problems, it helps a lot to draw a picture ------------------------------------------------------------------------------ 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. Even the stop coordinate must be in the maze in order for the maze to be solvable. [Note: I know that the stop coordinate is not in the maze for the following two examples.] A. Consider the example maze ((1 1)(2 1)(3 1)(4 1)(1 2)(1 3)(1 4)), with start coordinate (1 1) and stop coordinate (3 3). Consider the 3 search strategies: BFS, DFS and IDS. For each pair of strategies, state whether the time complexity is the same or different on this example, and state the reason why. Do the same thing for space complexity. B. Consider the example maze ((1 1)(1 2)(2 2)(2 1)), with start coordinate (1 1) and stop coordinate (3 3). Consider the 3 search strategies: BFS, DFS and IDS. For each pair of strategies, state whether the time complexity is the same or different on this example, and state the reason why. Do the same thing for space complexity. C. What do the examples form part A and B tell you about the completeness and optimality of the 3 strategies. ------------------------------------------------------------------------------ Problem 2: Consider the relaxed version of the maze problem from question 1, such that every coordinate is in the maze (In other words, remove the restriction that you can only move to a coordinate in the maze). It is easy to calculate the exact solution from a given coordinate to the stop coordinate. Use the exact solution for the relaxed problem as a heuristic for the original maze problem. Give all the f values determined by the A* algorithm for the following maze: ((2 1)(3 1)(4 1)(5 1)(2 2)(5 2)(1 3)(2 3)(3 3)(4 3)(5 3) (1 4)(1 4)(2 5)(3 5)(4 5)) with start coordinate (3 1) and stop coordinate (4 5). ------------------------------------------------------------------------------ Problem 3: This problem involves a 2 person game, derived from the maze problem. In this problem, you are given a 4x4 grid, and a move consists of moving up, down, left or right one space, just like in the original maze problem. The only difference is that in this problem you can move to any coordinate in the grid (there is no maze to tell you where you are allowed to move). You start at position (3 3). Some of the squares have point values, as follows: (1 1) has point value 4, (2 1) has point value 10, (3 1) has point value 9, (4 1) has point value 11, (1 2) has point value 5, (4 2) has point value 12, (1 3) has point value 3, (4 3) has point value 6, (1 4) has point value 8, (2 4) has point value 2, (3 4) has point value 7, (4 4) has point value 1. You make the first move, from the start coordinate, your opponent moves from where you left off, you move from where your opponent left off, etc. Note: neither of you can move to a place where either you or your opponent has landed before. The game is over when you or your opponent lands on a square that has a point value. Your objective is to maximize the point value. Your opponent's objective is to minimize the point value. It does not matter which of you ends the game. Show the tree created by the algorithm for the given example, using the Alpha Beta Pruning algorithm. Number the nodes, so I can see in which order they were visited. Make sure it is clear where you have pruned the tree. ------------------------------------------------------------------------------ Problem 4: Consider the Towers of Hanoi problem. There are 3 pegs, and n circular disks with holes in the middle. At the beginning, the disks are stacked on the first peg such that no disk is on top of a smaller one. The objective is to move all the disks to the third peg. A move is to move a disk from one peg to another one, such that it is not put on top of a smaller disk. Represent this problem as a search problem in LISP-like notation, as I did in assignment 2. (In other words, give the states, operators, initial state, and goal state, so they could be used by a LISP function).