Prolog Assignment – Monkey and Bananas

 

 

Due at noon April 8, 2002.

The monkey and bananas problem:

 

A monkey is in a room with a box.  There are bananas hanging from a hook, too high for the monkey to reach.  The monkey can walk from one place to another on the floor.  If there is a box at the same place as the monkey, the monkey can push the box to another place, or can climb to the top of the box.  If the box is under the bananas and the monkey is on top of it, the monkey can grab the bananas.

 

Write a prolog program to solve this using the same approach used by the farmer-fox-goose-grain program we will discuss in class.

 

Represent locations as follows::

·        floor(a), floor(b), etc., represent locations on the floor.

·        over(a), over(b), etc., represent locations on the ceiling, with, e.g., over(a) located directly above floor(a)

·        topof(box1) represents the top of box1.

 

Rules about the actions:

·        The monkey can walk from any place on the floor to any other place on the floor, but cannot walk to or from places not on the floor.

·        If the monkey and a box are at the same place and this place is on the floor, the monkey can push the box to any other place on the floor, with the result that the box and the monkey are now at this other place.

·        If the monkey and a box are at the same place, the monkey can climb the box, with the result that the monkey is at topof(box).

·        If the monkey is at topof(box) and the box is at floor(X) and the bananas are at over(X), the monkey can grab the bananas, with the result that the monkey has the bananas.

In the initial state the monkey is at floor(a) , the box box1 is at floor(b) and the bananas are at over(c).

 

Be sure to use iterative deepening as the farmer-etc. example does.

 

Hand in your code with the handin program to group cs520-proj2.