CS 484 - Artificial Intelligence
Fall 2007


Loyola College > Department of Computer Science > CS 484 > Labs & Projects > Lab 1

Due

Thursday, September 20th at the beginning of class.
Lab will be penalized 20% for each class meeting after the due date.

CONTENTS


INTRODUCTION

For this lab you may work in pairs to implement the Farmer Crossing the River puzzle for state space search. In this problem, a farmer is on one side of a river and wishes to cross the river with a wolf, a chicken, and a bag of grain. He can take only one item at a time in his boat with him. He can't leave the chicken alone with the grain, or it will eat the grain, and he can't leave the wolf alone with the chicken, or the wolf will eat the chicken. How does he get all three safely across to the other side?


LAB INSTRUCTIONS

  1. Create a representation of the Farmer Crossing the River problem.
  2. Draw the complete search tree.
  3. Implement the represenation using Dr. Lisa Meeden's implemention of a general state space search algorithm in Python. Save search.py to your own directory. Read through the class definitions to understand how search is implemented.
  4. An example problem domain to be used in conjunction with state space search called the water pitcher puzzle has also been implemented. In this puzzle you are given a three-quart pitcher and a four-quart pitcher. Either pitcher can be filled from a faucet. The contents of either pitcher can be poured down a drain. Water may be poured from one pitcher to the other. When pouring, as soon as the pitcher being poured into is full, the pouring stops. There is no additional measuring device and and the pitchers have no markings to show partial quantities. A typical problem might be, what actions would you need to do in order to go from two empty pitchers, to exactly two quarts in the four-quart pitcher?

    Save pitcher.py to your own directory. Read through the class definition to understand how the PitcherState class works in conjunction with the Search class.

  5. Using the PitcherState class as a model, write a FarmerState class that implements the Farmer Crossing the River problem. Once implemented, you should be able to conduct a search using the following command:
    Search(FarmerState(<arguments>), FarmerState(<arguments>))
    

HAND IN

Email me your farmer.py file. Make sure that the file contains both names in it. Turn in your drawing of the search tree and answer the following questions:

  1. Does the program find the best answer?
  2. Why did you choose the particular represenation you did?