Menu


Notice: Undefined index: url2 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 84

Notice: Undefined index: url3 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 85

Notice: Undefined index: url4 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 86

Notice: Undefined index: opurl2 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 89

Notice: Undefined index: opurl3 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 90

Notice: Undefined index: opurl4 in /home/u681245571/domains/studyglance.in/public_html/labprograms/aidisplay.php on line 91

Artificial Intelligence [ Lab Programs ]


Aim:

Write a program in prolog to solve Monkey banana problem

Solution :

/* Description:

Imagine a room containing a monkey, chair and some bananas. That have been hanged from the center of ceiling. If the monkey is clever enough he can reach the bananas by placing the chair directly below the bananas and climb on the chair . 

The problem is to prove the monkey can reach the bananas.

The monkey can perform the following actions:
1) Walk on the floor
2) Climb the box
3) Push the box around(if it is beside the box).
4) Grasp the banana if it is standing on the box directly under the banana.

*/

% Production rules:

can_reach 🡪 clever,close.
get_on: 🡪 can_climb.

under 🡪 in room,in_room, in_room,can_climb.
Close 🡪 get_on,under | tall

% Clauses:

in_room(bananas).
in_room(chair).
in_room(monkey).
clever(monkey).
can_climb(monkey, chair).
tall(chair).
can_move(monkey, chair, bananas).
can_reach(X, Y):-clever(X),close(X, Y).
get_on(X,Y):- 
	can_climb(X,Y).
under(Y,Z):-
	in_room(X),in_room(Y),
	in_room(Z),can_climb(X,Y,Z).
close(X,Z):-
	get_on(X,Y), under(Y,Z);
	tall(Y).

Output:

% Queries:

 ?- can_reach(A, B).
 A = monkey.
 B = banana.

 ?- can_reach(monkey, banana).
 Yes.

Related Content :

Artificial Intelligence Lab Programs

1) Write a program in prolog to implement simple facts and Queries View Solution

2) Write a program in prolog to implement simple arithmetic View Solution

3) Write a program in prolog to solve Monkey banana problem View Solution

4) Write a program in prolog to solve Tower of Hanoi View Solution

5) Write a program in prolog to solve 8 Puzzle problems View Solution

6) Write a program in prolog to solve 4-Queens problem View Solution

7) Write a program in prolog to solve Traveling salesman problem View Solution

8) Write a program in prolog for Water jug problem View Solution