AI Lab Manual
AI Lab Manual
TECHNOLOGY MEERUT
To be prepared during / after the classes (not prior to the commencement of the classes)
11 Students Lists
12 Personal and Class Time-table
13 Lab Performance Record (Continuous Evaluation)
Record of CO-Attainment (as per OBE-06B) and Actions taken / to
14
be taken to improve attainment / academic performance
Attendance Register with Lab Plan / Performance Record
15
(completed)
16 Sessional Marks (AM-09 and Marks Uploaded to AKTU)
Record of Evaluated Lab Records (all tests, all sheets, Jobs),
17
Quizzes / Viva, Duly filled Course End Survey etc.
18 Any Other
Meerut Institute of Engineering and Technology, Meerut
Department of Information Technology
Lab Manual Artificial Intelligence Lab 2023-24
Vision
To be an outstanding institution in the country imparting technical education, providing need-
based, value-based and career-based programmes and producing self-reliant, self-sufficient
technocrats capable of meeting new challenges.
Mission
The mission of the institute is to educate young aspirants in various technical fields to fulfill
global requirement of human resources by providing sustainable quality education, training
and invigorating environment besides molding them into skilled competent and socially
responsible citizens who will lead the building of a powerful nation.
Objectives
The objective of the institute is to have necessary instruments and resources to deliver
technical manpower that not only meets the local industry requirements but is also an
acceptable human resource for the global job market in Management & Technology as well
as Master in Computer Application and other technological sectors. We aim to provide
quality technical education facilities to every student admitted to the institute along with the
development of all round personality of the students. To be a technically high and
professional institute, we ensure to provide most competent staff and excellent support
facilities like well-equipped library, lecture theaters, computer and scientific laboratories
fitted with high quality equipment. The institute organizes in-house and outside training
programmes, seminars, conferences and workshops on continuous basis and encourages
participation of staff and students to improve its Academic Pedagogy through innovative
ideas and techniques in order to impart quality education. To fill the perception gap between
expectation of industry and preferences of academia through industry institute cell, we
organize interactive sessions in the campus. To produce competitive professionals for
meeting the upcoming demand of the nation, the institute will always remain dedicated to the
social causes of the public of this region.
DEPARTMENT VISION AND MISSION
Vision
Mission
M1: To provide quality education in the core and applied areas of information
technology, and develop students from all socio-economic levels into globally
competent professionals.
M3: To invigorate students skills so that deploy their potential in research and
development, and inculcate the habit of lifelong learning.
Program Educational Objectives, Program Outcomes, Program
Specific Outcome, Course Outcomes and Mapping with POs
PEO 2: To bring the physical, analytical and computational approaches of IT to solve real
world Engineering problems and provide innovative solutions by applying appropriate
models, tools and evaluations.
PEO 4: Students to imbibe professional attitudes, team spirit, effective communication and
contribute ethically to the needs of the society with moral values.
PEO 5: Encourage students for higher studies and entrepreneurial skills by imparting the
quality of lifelong learning in emerging technologies and work in multidisciplinary roles and
capacities.
Program Outcomes
2. Problem analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in ltidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change
Program Specific Outcomes
1. PSO 1: Ability to understand, apply and analyze computational concepts in the areas
related to algorithms, machine learning, multimedia, web designing, Data Science, and
networking on the systems having different degree of complexity.
5 4 CO2 Write a program of prolog for DFS and BFS PPT Notes
2 I. Bratko, “Prolog: Programming for Artificial Intelligence”, Fourth edition, Addision-Wesley Educational Publishers Inc., 2011
M.Tim Jones, Artificial Intelligence: A Systems Approach(Computer Science), Jones and Bartlett Publishers, Inc. First Edition,
3
2008.
4 Nils J. Nilsson, The Quest for artificial intelligence, Cambridge University press, 2009
5 William F. Clocksin and Christopher S. Mellish, Programming in Prolog: Using the ISO standard, Fifth Edition, Springer, 2003.
6 Gerhard Weiss, Multi Agent Systems, Second Edition, MIT Press, 2003
Meerut Institute of Engineering and Technology, Meerut
Statements of Course Outcomes (COs) and Mapping with Program Outcomes (POs) and Program Specific Outcomes (PSOs)
BKL # K1 – Remember, K2 – Understand, K3 – Apply, K4 – Analyze, K5 – Evaluate, K6 – Create
Subject / Course Name : B.Tech (AI Lab) Name of Faculty / Subject Head : Mr. Rahul Singh Theory / Lab
PO PO PO PO PO PO PO PO PO PO PO PO PSO PSO PSO PSO
Statement of Course Outcomes (COs) Kx
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4
Design/development of
Communications
S. No. Sub Code COx Statement of Course Outcomes (COs)
solutions
finance
Ethics
Upon completion of topic concerned, students will be
able to :
1
Formulate the Necessity of Knowledge representiaon and
CO-3 experiment the presence of incomplete or Uncertain K2 1 1 1 1 1 2 1.00
informaiton
KIT 751A K3 1.33 1.00 2.00 1.50 1.00 1.30 1.00 2.00 2 1.00 1.00
Rules
Meal(X):- food (X) // Every food is a meal OR anything is a meal if it is food
Queries/ Goal
?- food(pizza) // Is pizza a food?
?- meal(X), lunch(X) // Which food is meal and lunch?
?-dinner(Sandwich). // Is sandwich a dinner?
EXPERIMENT: 2
WRITE A PROGRAM OF USING ARITHMETIC OPERATORS IN PROLOG
AIM
Write a program of using arithmetic operators in prolog.
Platform: Windows 7/ SWI- Prolog.
Program.
?-X is 10+5
X=15
Yes
?-X is 10-5
X=5
Yes
?-X is 10*5
X= 50
Yes
?-X is 10/5
X=2
Yes
?-X is 10+5*6/3
X=20
Yes
?-power(3,2,P)
P=8
Yes
?-R is mod(7,2)
R=1
yes
EXPERIMENT: 3
WRITE A PROGRAM TO IMPLEMENT FAMILY TREE WITH PREDICATES
LIKE FATHER, MOTHER, SON, DAUGHTER, GRANDFATHER, AUNT, UNCLE,
COUSIN, ANCESTOR FOR FACTS LIKE MALE, FEMALE, PARENT, BROTHER,
SISTER.
AIM-Write a program to Implement family tree with predicates like father, mother, son,
daughter, grandfather, aunt, uncle, cousin, ancestor for facts like male, female, parent,
brother, sister.
Platform: Window 7/ SWI- Prolog
Program:
male(shankar).
male(ulhas).
male(satish).
male(saurabh).
male(prashant).
female(umabai).
female(mrunal).
female(sadhana).
female(swati).
parent(shankar,umabai,ulhas).
parent(shankar,umabai,satish).
parent(ulhas,mrunal,prashant).
parent(satish,sadhana,saurabh).
parent(satish,sadhana,swati).
brother(ulhas,satish).
brother(satish,ulhas).
brother(prashant,saurabh).
brother(saurabh,prashant).
sister(swati,saurabh).
sister(swati,prashant).
father(X,Y):- parent(X,Z,Y).
mother(X,Y):- parent(Z,X,Y).
wife(X,Y) :- female(X),parent(Y,X,Z).
ancestor(X,Y,Z):-parent(X,Y,Z).
ancestor(X,Y,Z):- parent(X,Y,W), ancestor(W,U,Z).
**********************Output**********************
I ?- father(X,Y).
X=shankar
Y = ulhas;
X=shankar
Y = satish;
X=ulhas
Y = prashant ;
X=satish
Y = saurabh ;
X=satish
Y = swati ;
No
**************************************************************
2 ?- mother(X,Y).
X=umabai
Y = ulhas;
X=umabai
Y = satish;
X=mrunal
Y = prashant ;
X=sadhana
Y = saurabh ;
X=sadhana
Y = swati ;
No
*************************************
3 ?- parent(X,Y,Z).
X=shankar Y=umabai
Z = ulhas;
X=shankar Y=umabai
Z = satish;
X=ulhas Y=mrunal
Z = prashant ;
X=satish Y=sadhana
Z = saurabh ;
X=satish
Y=sadhana
Z = swati ;
No
*******************************************
4?- son(prashant,X,Y).
X=ulhas
Y = mrunal
Yes
*******************************************
5?- daughter(swati,X,Y).
X=satish
Y = sadhana
Yes
*********************************************
7?- grandfather(X,Y).
X=shankar
Y = prashant ;
X=shankar
Y = saurabh ;
X=shankar
Y = swati ;
No
************************
7?- aunt(X,Y).
X=mrunal
Y = saurabh ;
X=mrunal
Y = swati ;
X=sadhana
Y = prashant ;
X=sadhana
Y = prashant ;
No
************************
8 ?- uncle(ulhas,X).
X = saurabh ;
X = swati ;
No
*************************
9 ?- cousin(X,Y).
X=prashant
Y = saurabh ;
X=prashant Y = swati ;
X=saurabh
Y = prashant ;
X=swati Y = prashant ;
**********************************
No
*******************************
10 ?- ancestor(X,Y,prashant).
X=ulhas
Y = mrunal;
X=shankar Y = umabai ;
No
EXPERIMENT: 4
WRITE A PROGRAM OF LISTS.
AIM
Write a program of lists.
Platform: Windows 7/ SWI- prolog
Program:
There is an empty list as [ ].
Head and Tail of the lists:
head the 1st element of the list.
tail: all elements of the list except the 1stone
Syntax: [HT]
(a) length of a list
size([],0).
size([HT],N):- size(T,N1), N is N1+1.
% or size([T],N) :- size(T,N1), N is N1+1.
|?- size([1,2,3,4],N).
N=4
yes
| ?-size([bill,ted,ming,pascal,nat,ron],N).
N=6
yes
| ?- size([a, [b, c, d], e, [f| g], h], N).
N=5
Yes
member(X,[X]).
member(X,[T]):- member(X,T).
(d) reversing a list
reverse(List, Reversed) :-
reverse(List, [], Reversed).
reverse([], Reversed, Reversed).
reverse([Head Tail], SoFar, Reversed) :-
reverse(Tail, [Head|SoFar], Reversed).
| ?- myreverse([a,b,c,d],X).
X = [d,c,b,a];
<- note semicolon (more solns?)
no
!?- myreverse([a,b,c,d],[d,b,c,a]).
no
!?- myreverse([a,b,c,d],[d,c,b,a]).
yes
- note difference between reverse/2 and reverse/3 - reverse/3 probably should be called
reverseHelper or something else for clarity
EXPERIMENT: 5
WRITE A PROGARM IN PROLOG FOR DEPTH FIRST SEARCH
AIM
Write a program in prolog for Depth first search.
Platform: Windows 7/ SWI- Prolog
Program:
Child(a,b) /* b is child of a*/
Child(a,c) /* c is child of a*/
Child(a,d) /* d is child of a*/
Child(b,e) /* e is child of b*/
Child(b,f) /* f is child of b*/
Child(c,g) /* g is child of c*/
Childnode(A,G,[G]:- child(A,G))
Childnode(A,G,[X|L]):-child(A,X), childnode(X,G,L)
Path(A,G,[A|Z]):- childnode(A,G,Z) /* to find path between root to leaf*/
Result:
?_path(a,e,L)
L=[a,b,e]
EXPERIMENT: 6
WRITE A PROGRAM IN PROLOG TO SOLVE TOWER OF HANOI
AIM
Write a program in prolog to solve Tower of Hanoi.
Platform: Windows 7/ SWI- prolog
Program:
The 3-disk setup is like this:
XXX
XXXXX
XXXXXXX
Here's a sample:
% move(N,X,Y,Z) - move N disks from peg X to peg Y, with peg Z being the % auxilliary
peg%
% Strategy:
% Base Case: One disc - To transfer a stack consisting of 1 disc from
% peg X to peg Y, simply move that disc from X to Y
% Recursive Case: To transfer n discs from X to Y, do the following:
Transfer the first n-1 discs to some other peg X
Move the last disc on X to Y
Transfer the n-1 discs from X to peg Y
move(1,X,Y,_):-
write('Move top disk from '),
write(X),
write(' to '),
write(Y),
nl.
move(N,X,Y,Z):-
N>1,
M is N-1,
move(M,X,Z,Y),
move(1,X,Y,_),
move(M,Z,Y,X).
- note the use of "anonymous" variables
Here is what happens when Prolog solves the case N=3.
?- move(3,left,right,center)
Move top disk from left to right
Move top disk from left to center
Move top disk from right to center
Move top disk from left to right
Move top disk from center to left
Move top disk from center to right
Move top disk from left to right
Yes
EXPERIMENT: 7
WRITE A PROGRAM IN PROLOG FOR JUG PROBLEM
USING HEURISTIC FUNCTION
AIM
Write a program in prolog for Water jug problem using heuristic function.
Platform: Windows 7/ SWI- prolog
Program:
database
visited_state(integer, integer)
predicates
state(integer, integer)
clauses
state(2,0).
state(X,Y):- X<4,
not(visited_state(4,Y)),
assert(visited_state(X,Y)),
write("Fill the 4-Gallon Jug: (",X,",",Y,") - -->(", 4,",",Y,")\n"), state(4,Y).
state(X,Y):- Y<3,
not(visited_state(X,3)),
assert(visited_state(X,Y)),
write("Fill the 3-Gallon Jug: (", X,",",Y,") --> (", X,",",3,")\n"), state(X,3).
state(X,Y):- X>0,
not(visited_state(0,Y)),
assert(visited_state(X,Y)),
write("Empty the 4-Gallon jug on ground: (", X,",",Y,") --> (", 0,",",Y,")\n"), state(0,Y).
not(visited_state(X,0)),
assert(visited_state(X,0)),
state(X,Y):- Y> 0,
write("Empty the 3-Gallon jug on ground: (", X,",",Y,") --> (", X,",",0,")\n"), state(X,0).
state(X,Y):- X + Y >= 4,
Y > 0,
NEW_YY - (4 - X),
not(visited_state(4,NEW_Y)),
assert(visited_state(X,Y)),
write("Pour water from 3-Gallon jug to 4-gallon until it is full: (", X,",",Y,") --> (",
4,",",NEW_Y,")\n"),
state(4,NEW_Y).
state(X,Y):- X + Y >=3,
X > 0,
NEW X-X-(3 - Y), not(visited_state(X,3)), assert(visited_state(X,Y)),
write("Pour water from 4-Gallon jug to 3-gallon until it is full: (", X,",",Y,") --> (", NEW
X,",",3,")\n"),
state(NEW_X,3).
state(X,Y):- X + Y <=4,
Y > 0,
NEW X=X+Y,
not(visited_state(NEW_X,0)),
assert(visited_state(X,Y)),
write("Pour all the water from 3-Gallon jug to 4-gallon: (", X,",",Y,") --> (",
NEW_X,",",0,")\n"),
state(NEW_X,0).
state(X,Y):- X+Y<=3, X > 0,
NEW Y=X+Y,
not(visited_state(0,NEW_Y)),
assert(visited_state(X,Y)),
write("Pour all the water from 4-Gallon jug to 3-gallon: (", X,",",Y,") --> (",
0,",",NEW_Y,")\n"),
state(0,NEW_Y).
state(0,2):- not(visited_state(2,0)),
assert(visited_state(0,2)),
write("Pour 2 gallons from 3-Gallon jug to 4-gallon: (", 0,",",2,") --> (", 2,",",0,")\n"),
state(2,0).
state(2,Y):- not(visited_state(0,Y)),
assert(visited_state(2,Y)),
write("Empty 2 gallons from 4-Gallon jug on the ground: (", 2,",",Y,") --> (",
0,",",Y,")\n"),
goal
state(0,Y).
makewindow(1,2,3,"4-3 Water Jug Problem",0,0,25,80),
state(0,0).
OUTPUT
Fill the 4-Gallon Jug: (0,0)(4,0)
Fill the 3-Gallon Jug: (4,0) (4,3)
Empty the 4-Gallon Jug on Ground: (4,3)(0,3)
Pour all the water from 3-Gallon jug to 4-Gallon: (0,3)(4,2)
Empty the 4-Gallon jug on ground: (4,2) (0,2)
Pour all the water from 3-Gallon jug to 4-Gallon: (0,2)(2,0)
EXPERIMENT: 8
WRITE A PROGRAM IN FOR EXPERT SYSTEM BY USING
FORWARD CHAINING AND ALSO WRITE PROBLEMS OF AI
DOMAIN AND AI TECHNIQUES
AIM
Write a program for expert system by using forward chaining and also write
problems of AI domain and AI techniques.
Problems of AI Domain
1. Mundane Tasks
2. Formal Tasks
3. Expert Tasks
Mundane Tasks
- Perception
-Vision
- Speech
Natural Language
-Understanding
- Generation
- Translation
- Commonsense reasoning
- Robot Control
Formal Tasks
Games
-Chess, Backgammon, Checkers, Go
Mathematics
- Geometry, Logic, Integral Calculus, Proving properties of programs
Expert Tasks
Engineering
Design, Fault Finding, Manufacturing Planning
Scientific Analysis
Medical Diagnosis
Financial Analysis
The AI Technique
Intelligence requires knowledge
Voluminous
Hard to characterize accurately
Constantly changing
To be organized in a way to be used
AI Methods should exploit knowledge
Generalization
Input comes as 'human understandable form'
Modifiable with meta-knowledge
Usable even when incomplete or not totally accurate
Medical diagnosis
Platform: Windows 7/ SWI- prolog
Program:
domains
disease, indication,name = symbol
predicates
hypothesis(name,disease)
symptom(name,indication)
clauses
symptom(amit,fever).
symptom(amit,rash).
symptom (amit,headache).
symptom(amit,runn_nose).
symptom (kaushal,chills).
symptom(kaushal,fever).
symptom(kaushal,hedache).
symptom(dipen,runny_nose).
symptom(dipen,rash).
symptom(dipen,flu).
hypothesis(Patient,measels):-
symptom(Patient, fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,rash).
hypothesis(Patient,german_measles) :-
symptom(Patient,fever),
symptom(Patient, headache),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis (Patient,flu) :-
symptom (Patient,fever),
symptom(Patient,headache),
symptom (Patient,body_ache),
symptom(Patient,chills).
hypothesis(Patient,common_cold) :-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,chills),
symptom(Patient,runny_nose).
hypothesis(Patient,mumps) :-
symptom(Patient,fever),
symptom(Patent, swollen_glands).
Hypothesis(patient,chicken_pox):-
Symptom(patient,fever),
Symptom(patient,rash),
Symptom(patient,body_ache),
Symptom(patient,chills),
EXPERIMENT: 9
WRITE A PROGRAM TO SOLVE 8-PUZZLE PROBLEM
AIM
Write a program to solve 8-Puzzle problem.
The title of this section refers to a familiar and popular sliding tile puzzle that has been
around for at least forty years. The most frequent older versions of this puzzle have numbers
or letters an the sliding tiles, and the player is supposed to slide tiles into new positions in
order to realign a scrambled puzzle back into a goal alignment. For illustration, we use the 3
x 3 8-tile version, which is depicted here in goal configuration
7 2 3
4 6 5
1 8
To represent these puzzle "states" we will use a Prolog term representation employing '/' as a
separator. The positions of the tiles are listed (separated by '/') from top to bottom, and from
left to right. Use "O" to represent the empty tile (space). For example, the goal is
goal(1/2/3/8/0/4/7/6/5).
Production Rules :-
n_function(Puzz,H) p_fcn (Puzz,P), s_fcn(Puzz,S), H is P + 3*S.
The heuristic function we use here is a combination of two other estimators: p_fcn, the
Manhattan distance function, and s_fcn, the sequence function, all as explained in Nilsson
(1980), which estimates how badly out-of-sequence the tiles are (around the outside).
h_function(Puzz,H):- p_fcn (Puzz,P),
H is P + 3*S.
s_fcn(Puzz,S),
The 'move' predicate is defined as follows. move(P,C,left)-left(P,C). move(P,C,up) :-
up(P,C). move(P,C,right) :- right(P,C). move(P,C,down) :- down(P,C). Here is the code for p
and s. %%% Manhattan distance p_fcn(A/B/C/D/E/F/G/H/I, P) :- a(A,Pa), b(B,Pb), c(C,Pc),
d(D,Pd), e(E,Pe), f(F,Pf),
g(G,Pg), h(H,Ph), i(l,Pi),
P is Pa+Pb+Pc+Pd+Pe+Pf+Pg+Ph+Pg+Pi.
a(0,0). a(1,0). a(2,1). a(3,2). a(4,3). a(5,4). a(6,3). a(7,2). a(8,1). b(0,0). b(1,0). b(2,0). b(3,1).
b(4,2). b(5,3). b(6,2). b(7,3). b(8,2). c(0,0). c(1,2). c(2,1). c(3,0). c(4,1). c(5,2). c(6,3). c(7,4).
c(8,3). d(0,0). d(1,1). d(2,2). d(3,3). d(4,2). d(5,3). d(6,2). d(7,2). d(8,0). e(0,0). e(1,2). e(2,1).
e(3,2). e(4,1). e(5,2). e(6,1). e(7,2). e(8,1). f(0,0). f(1,3). f(2,2). f(3,1). f(4,0). f(5,1). f(6,2).
f(7,3). f(8,2). g(0,0). g(1,2). g(2,3). g(3,4). g(4,3). g(5,2). g(6,2). g(7,0). g(8,1). h(0,0). h(1,3).
h(2,3). h(3,3). h(4,2). h(5,1). h(6,0). h(7,1). h(8,2). (0,0). (1,4). i(2,3). i(3,2). i(4,1). i(5,0).
i(6,1). i(7,2). i(8,3).
%%% the out-of-cycle function s_fcn (A/B/C/D/E/F/G/H/I, S) :-
s_aux(A,B,S1), s_aux(B,C,S2), s_aux(C,F,S3),
s_aux(F,I,S4), s_aux(I,H,S5), s_aux(H,G,S6),
s_aux(G,D,S7), s_aux(D,A,S8), s_aux(E,S9),
S is S1+S2+S3+S4+S5+S6+S7+S8+S9.
s_aux(0,0):- !. s_aux(_,1).
s_aux(X,Y,O) :- Y is X+1, !.
s_aux(8,1,0):- !. s_aux(__2).
The Prolog program from the previous section and the program outlined in this section can be
used as an 8-puzzle solver. ?- solve(0/8/1/2/4/3/7/6/5, S).
7 2 3
A 4 6 5
1 8 0
step 1 7 2 3 7 2 3
B 4 6 0 C 4 6 5
1 8 5 1 0 8
step 2 7 2 3 7 2 0 7 2 3
D 4 6 5 E 4 6 3 F 4 0 6
1 8 0 1 8 5 1 8 5
step 3 7 2 3 7 0 2
G 4 6 0 H 4 6 3
1 8 5 1 8 5
Solution:
left(A/O/C/D/E/F/H/I/J, O/A/C/D/E/F/H/I/J).
left(A/B/C/D/O/F/H/I/J, A/B/C/O/D/F/H/I/J).
left( A/B/C/D/E/F/H/O/J, A/B/C/D/E/F/O/H/J).
left(A/B/O/D/E/F/H/I/J, A/O/B/D/E/F/H/I/J).
left( A/B/C/D/E/O/H/1/J, A/B/C/D/O/E/H/I/J).
left( A/B/C/D/E/F/H/I/O, A/B/C/D/E/F/H/0/1).
up(A/B/C/O/E/F/H/I/J, O/B/C/A/E/F/H/I/J).
up(A/B/C/D/O/F/H/I/J, A/O/C/D/B/F/H/I/J).
up( A/B/C/D/E/O/H/I/J, A/B/O/D/E/C/H/I/J).
up(A/B/C/D/E/F/O/1/J, A/B/C/O/E/F/D/I/J).
up( A/B/C/D/E/F/H/O/J, A/B/C/D/O/F/H/E/J).
up( A/B/C/D/E/F/H/I/O, A/B/C/D/E/O/H/I/F).
right(A/O/C/D/E/F/H/I/J, A/C/O/D/E/F/H/I/J).
right(A/B/C/D/O/F/H/I/J, A/B/C/D/F/O/H/I/J).
right(A/B/C/D/E/F/H/O/J, A/B/C/D/E/F/H/J/O).
right(O/B/C/D/E/F/H/I/J, B/O/C/D/E/F/H/I/J).
right(A/B/C/O/E/F/H/I/J, A/B/C/E/O/F/H/I/J).
right(A/B/C/D/E/F/0/1/J, A/B/C/D/E/F/1/0/J).
down(A/B/C/O/E/F/H/I/J, A/B/C/H/E/F/O/I/J).
down(A/B/C/D/O/F/H/I/J, A/B/C/D/I/F/H/O/J).
down(A/B/C/D/E/O/H/I/J, A/B/C/D/E/J/H/I/O).
down(U/B/C/D/E/F/H/I/J, D/B/C/O/E/F/H/I/J).
down(A/O/C/D/E/F/H/I/J, A/E/C/D/O/F/H/I/J).
down( A/B/O/D/E/F/H/I/J, A/B/F/D/E/O/H/I/J).
EXPERIMENT: 10
WRITE A PROGRAM TO SOLVE MONKEY BANANA PROBLEM
AIM
Write a program to solve monkey banana problem
Platform: Window 7/ SWI-prolog
Program:
push(P1, P2).
walk(P1,P2).
grasp.
climb.
state(MH,MV,BP,HB).
move(State),Move,State2).
move( State(P, onfloor, P,H),
climb,
state(P, onbox, P, H)).
move(State(P1,onfloor, P1,H),
push(P1,P2),
state(P2,onfloor,P2,H)).
move(state(P1,onfloor,B,H),
walk(P1,P2),
state(P2,onfloor,B,H)).
move(State(middle,onbox,middle,hasnot), /*before move*/
grasp,
state(middle,onbox,middle,has)).
canget(state(_,_,__,has)).
canget(State):-
move(Statel,Move,State2),
canget(State2).
/* get it now*/
Result:
?-canget(atdoor, at floor,window,hasnot).
No solution.
IT Final Year Student List