CS 662: AI Programming

Homework #3: Search

Assigned: September 13
Due: September 20.
30 points

To turn in: Typed answers to the questions throughout the homework, along with a hard copy of your source code. Also, please place a copy of your code in your submit directory.

In this assignment, you'll be helping the members of the rock band U2 get to a concert on time.

Consider the following problem:
U2 has a concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each band member walks at a different speed. A pair must walk together at the rate of the slower man's pace:

Bono: 1 minute to cross
Edge: 2 minutes to cross
Adam: 5 minutes to cross
Larry: 10 minutes to cross

For example: if Bono and Larry walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Larry then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission.

(note: this is a fairly well-known puzzle, and solutions to it undoubtedly can be found on the Web. I would suggest that you try to solve it yourself first. This will give you a much better understanding of the problem.)

Note: This homework is larger than the previous two homeworks. As a point of comparison, I wrote the code in an evening, using about 175 lines of fairly-compact Python (with several list comprehensions). Since I'm familiar with both Python and the subject matter, you should budget your time accordingly. I also strongly recommend unit testing each component of this program as you build it. It's much easier to debug the successor function independently of the search algorithm.

  1. (2 points) (Warm-up) Solve the problem by hand. What sequence of moves will get the band members to the other side of the bridge in 17 minutes or less?
  2. (8 points) For the rest of the homework, you'll solve this problem using a variety of search algorithms. To begin with, create a Python class called U2State that indicates where each band member is at a given point in time, where the flashlight is, and how much time has elapsed. You may also find it useful to keep a pointer to the 'parent' state, so that you can print out the sequence of moves once they are found. You may choose how you wish to represent the state variables.
  3. Now you're ready to implement search algorithms to solve this problem.

Extra Credit: You may do either of the problems below (but not both). Each are worth 5 points extra credit.