Assignment 2

Assignment 2

Due Tuesday, January 19th in class.

The book's example code

To use the AIMA code, you should copy the directories (everything in CS250/Code/AIMA and below) to your computer. Next, follow the installation instructions, beginning with Installing the Code. When you get to step 2, be sure you use the directory format for the machine you're running on:

After step 4, you might get some warnings, but you shouldn't get any errors. You can try out the search stuff by typing:

(test 'search)

You're on your way! If you have trouble, try posting to the Homework forum and see if anyone (including me) can help.

Overview of all the example code

1) AIMA 3.4

Based on the joke in the book (which I repeated in class) you might think that the missionaries can't outnumber the cannibals. In fact, too many missionaries isn't a problem -- there's only trouble if the cannibals outnumber the missionaries.

For this problem, you need to pull together several pieces of code that are already written for you. To do breadth-first search, you'll want to combine the general search algorithm we discussed in class Thursday (see Lecture 2-2) with the right data structure.

Breadth-first search searches each level of the tree before moving on to the next level. (Depth-first follows one branch all the way before moving on to the next branch.) That's good because it will find a solution if one exists, and it will find the "shallowest" solution, but it could take a long time. The code is quite simple once you have GENERAL-SEARCH:

(defun breadth-first-search (problem)
   "Search the shallowest nodes in the search tree first. [p 74]"
   (general-search problem #'enqueue-at-end))

Of course the search is only half the battle, because you need to get the missionaries and the cannibals in there too. The example code includes much of what you'll need to set up the problem.

2) AIMA 3.5

3) AIMA 3.7

4) AIMA 3.19