CS475 - Artifical Intelligence I Fall 1997 Assignment 1 Due Thurs, Sept 18 =================== Part I. Understanding Lisp evaluation. In generate.lisp: I.1: What is wrong with the following version of rewrites? What error occurs? (Hint: Common Lisp uses lexical scoping) (defun helper (rule) (if (equal cat (rule-lhs rule)) (rule-rhs rule) nil)) (defun rewrites (cat) (apply #'append (mapcar #'helper *grammar*))) I.2: Can you make the following version work by filling in the missing parts appropriately? If so, show it. If not, explain why not. (defun helper (cat rule) (if (equal cat (rule-lhs rule)) (rule-rhs rule) nil)) (defun rewrites (cat) (mapcar #'helper ====================================================== Part II: Agents and problem characteristics. Chapter 2: problems 2.1 and 2.3. For 2.3, please choose a non-trivial domain, i.e., a problem for which state-space search, rather than a more direct approach, would be appropriate. ====================================================== Part III: Formulating a problem as a state-space problem, solving it in Lisp, and evaluating the results. Introduction: -------------- For this part of the assignment, you will use the search functions given in class to solve a problem. Once you implement goalp, successors, and h, you can run all of the search algorithms given to you. Please use the graph search file, which contains the most search algorithms and in which all algorithms save paths. Problem definition and suggested formulation: --------------------------------------------- The following is to get you started, but does not contain all details. Other issues will come up as you work on the problem. Please raise these issues in your documentation, and state what you decided to do. In a certain city, all of the streets run either North-South or East-West; all the building numbers increase as you move either South or West; and no number is used twice. The goal is to find a particular building number, given a particular starting address. Assume the lowest address is 0. Don't assume any particular upper limit on addresses; this will make the comparison of search strategies more interesting. I suggest the following representation of a state. Structures are very nice in Lisp, since the access functions are automatically defined for you. However, you will have to define an appropriate print function (defstruct state (number) ; the current house number you are in front of (east-west1) ; the two east west streets you are between (east-west2) (north-south1) ; the two north south streets you are between (north-south2)) There are four operators, one for a move in any of the 4 cardinal directions. The goal test is simply to see if the current building number is the goal number. When this assignment will be assigned, we will not have gotten yet to heuristic functions (function h). What you need to know: This function should map a state into a numerical estimate of the distance of the state to a goal; the lower the better. Requirements: ------------- Please include clear documentation describing your problem formulation. Your documentation should make it easy for me to run your code. To compare the performances of the various algorithms, use global variables to gather statistics during search. Evaluation criterion: Is any answer found? Assessment: does the program terminate? Does it fail? Evaluation criterion: Number of states considered (token vs type: if the same state is visited N times, we need to consider that as N visits) Assessment: the number of times goalp is called Evaluation criterion: Goodness of solution Assessment: you define this Evaluation criterion: Space requirements Assessment: average size of open during search Note: (setq X 0) treats X as a global variable. Hint: for a function that is composed of a cond statement, you can put such instructions with side effects before the cond statement. Write up your conclusions about the relative goodness and appropriateness of the various search algorithms for this problem. You will need to add some additional display code to make the results more readable. In particular, you should print out (node-state (first open)) as you go along to show the progress of the search. You may want to define a new ``print-state'' function, to make this more readable. For this question, please e-mail me your program and give me a hard-copy too. You can put your documentation and functions inside a copy of the graph-search (saving paths) file available on the Web.