0% found this document useful (0 votes)
34 views43 pages

AI Lab Manual

Lab manual of artificial intelligence sem 7 BE

Uploaded by

Afrin shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views43 pages

AI Lab Manual

Lab manual of artificial intelligence sem 7 BE

Uploaded by

Afrin shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

ARTIFICIAL INTELLIGENCE (3170716)

Lab Manual
Practical: 1

Aim: Write a program to implement Tic-Tac-Toe Game problem.


#include <stdio.h>
#include <conio.h>
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
int checkwin();
void board();
int main()
{
int player = 1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
printf( "Player %d",player);
printf(" enter a number: ");
scanf("%d",&choice);
mark=(player == 1) ? 'X' : 'O';
if (choice == 1 && square[1] == '1') square[1] = mark;
else if (choice == 2 && square[2] == '2')square[2] = mark;
else if (choice == 3 && square[3] == '3')square[3] = mark;
else if (choice == 4 && square[4] == '4')square[4] = mark;
else if (choice == 5 && square[5] == '5')square[5] = mark;
else if (choice == 6 && square[6] == '6')square[6] = mark;
else if (choice == 7 && square[7] == '7')square[7] = mark;
else if (choice == 8 && square[8] == '8')square[8] = mark;
else if (choice == 9 && square[9] == '9')square[9] = mark;
else
{
printf("\nInvalid move ");
player--;
getch();
}
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
{
printf("\nPlayer %d ",--player);
printf(" win ");
}
else
printf("\nGame draw");
getch();
return 0;
}
int checkwin()
{
if (square[1] == square[2] && square[2] == square[3]) return 1;
else if (square[4] == square[5] && square[5] == square[6]) return 1;
else if (square[7] == square[8] && square[8] == square[9]) return 1;
else if (square[1] == square[4] && square[4] == square[7]) return 1;
else if (square[2] == square[5] && square[5] == square[8]) return 1;
else if (square[3] == square[6] && square[6] == square[9]) return 1;
else if (square[1] == square[5] && square[5] == square[9]) return 1;
else if (square[3] == square[5] && square[5] == square[7]) return 1;
else if (square[1] != '1' && square[2] != '2' && square[3] != '3' && square[4] != '4' && square[5] != '5'
&& square[6] != '6' && square[7] != '7' && square[8] != '8' && square[9] != '9') return 0;
else
return -1;
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/
void board()
{
clrscr();
printf(" \n\n\tTic Tac Toe\n\n");
printf("Player 1 (X) - Player 2 (O)\n\n");
printf("\n");
printf(" | | \n");
printf(" %c" ,square[1]);
printf(" | %c",square[2]);
printf(" | %c",square[3]);
printf("\n");
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c" ,square[4]);
printf(" | %c",square[5]);
printf(" | %c",square[6]);
printf("\n");
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c" ,square[7]);
printf(" | %c",square[8]);
printf(" | %c",square[9]);
printf("\n");
}
Output:
Practical: 2

Aim: Write a Prolog Program to Demonstrate Family Relationship.

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).

son(X,Y,Z) :- male(X),father(Y,X),mother(Z,X).
daughter(X,Y,Z) :- female(X),father(Y,X),mother(Z,X).

wife(X,Y) :- female(X),parent(Y,X,Z).

grandfather(X,Y) :- male(X),father(X,Z),father(Z,Y).

uncle(X,Y) :- male(X),brother(X,Z),father(Z,Y).

aunt(X,Y) :- wife(X,Z),uncle(Z,Y).

cousin(X,Y) :- father(Z,X),brother(Z,W),father(W,Y).

ancestor(X,Y,Z) :- parent(X,Y,Z).
ancestor(X,Y,Z) :- parent(X,Y,W),ancestor(W,U,Z).
Output:
Practical: 3

Aim: Write a PROLOG program to find the addition of two numbers.


PROLOG PROGRAM:
sum:-write('Enter number1: '),read(N1),
write('Enter number2: '),read(N2),
A is N1+N2,write('Addition of two number: '),
write(A).

Output:
Practical: 4(a)

Aim: Give an opportunity to user to re-enter the password ‘n’ no. Of Times, on entering
wrong password.
PROLOG PROGRAM:
db(nirali,123).

go(X,Y):-write('Enter Username'),read(X), write('Enter Password'),read(Y).

login:-go(X,Y),db(X,Y),nl, write('your username & password are'),write(X),write(Y).

login:-write('....Incorrect Password try again....'),login.

OUTPUT:
Practical: 4(b)

Aim: Give an opportunity to user to re-enter the password three (03) Times, on
entering wrong password:

SWI PROLOG PROGRAM:

db(kelu,123).
db(patel,789).

go(X,Y):-write('Enter username:'),read(X) ,write('Enter password:'),read(Y).

login:-go(X,Y),db(X,Y),nl,write('Enter username and password are '),write(X),write(Y).

login:-write('Invalid password'),nl,login.

Output:
Practical: 5

Aim: Write a program to create Database for Hobbies of Different Person.

PROLOG PROGRAM:

hobby(kelu,gaming).
hobby(amita,dancing).
hobby(bhavini,playing).
hobby(poonam,painting).
hobby(nikunj,reading).

Output:
Practical: 6

Aim: Write a PROLOG program for diagnosis the childhood diseases.

PROLOG PROGRAM:

symtom(john,fever).

symtom(john,rashes).

symtom(john,stomachache).

symtom(john,running_nose).

symtom(john,body_ache).

dis(X,malaria):-symtom(X,fever),symtom(X,headache),symtom(X,running_nose).

dis2(X,jaundice):-symtom(X,fever),symtom(X,stomachache),symtom(X,body_ache).

Output:
Practical: 7

Aim: Write a PROLOG program To check if a given year is a Leap Year or not.
PROLOG PROGRAM:

go:- write('Enter the year'),nl,read(X),ckeck(X).

ckeck(X):- (N is (X mod 4),N > 0,write('year is not leap year');


N is 0,write('year is leap year')).

Output:
Practical: 8

Aim : Write a PROLOG program to find the factorial of a given number:

PROLOG PROGRAM:

factorial(0,1).
factorial(N,F):- N>0,N1 is N-1,factorial(N1,F1),F is N*F1.

Output:
Practical: 9

Aim: Write a PROLOG program to find Fibonacci series.

PROLOG PROGRAM:

go:-write('Enter term number: '),read(N),fibo(1,1,0,N).


fibo(_,_,_,0).
fibo(A,B,C,N):-AA is B,BB is C,CC is AA+BB,write(CC),NN is N-1,fibo(AA,BB,CC,NN).

Output:
Practical: 10

Aim: Write a PROLOG program based on list.


1) To find the length of a list.
PROLOG PROGRAM:
len_ls([],0).
len_ls([H|T],L):-len_ls(T,LL),L is LL+1.
Output:

2) To find whether given element is a member of a list.


PROLOG PROGRAM:
m1(E,[E|T]).
m1(E,[_|T]):-m1(E,T).
Output:
Practical: 11

Aim: Write a PROLOG program to solve WATER-JUG problem.


PROLOG PROGRAM:

jug(integer, integer).
jug(2, _).
jug(0, 2):-
write('(0, 2)'), nl,
write('(2, 0)'), nl.
jug(4, 0):-
write('(4, 0)'), nl,
jug(0, 0).
jug(4, 3):-
write('(4, 3)'), nl,
jug(0, 0).
jug(3, 0):-
write('(3, 0)'), nl,
jug(3, 3).
jug(X, 0):-
write('('),write(X),write(', 0)'), nl,
jug(0, 3).
jug(0, 3):-
write('(0, 3)'), nl,
jug(3, 0).
jug(0, X):-
write('(0,'),write(X),write(' )'), nl,
jug(0, 0).
jug(3, 3):-
write('(3, 3)'), nl,
jug(4, 2).
jug(4, 2):-
write('(4, 2)'), nl,
write('(2, 0)'), nl,
jug(2, 0).
jug(X, Y):-
X>4,
fail,
Y>3,
fail.
Output:
Practical: 12

Aim: Write a PROLOG program for TRAVELING SALESMAN problem.


SWI PROLOG PROGRAM:

read('surat','valsad',100).
read('valsad','pune',150).
read('pune','mumbai',100).
read('chikhli','navsari',50).
find:-write('Source center:'),read(City1),write('Dest center:'),read(City2),route(City1,City2,Dist).
route(City1,City2,Dist):-read(City1,City2,Dist),write('Distance bet. '),write(City1),write(' and '),write(City2),write('
is '),write(Dist),nl,nl.
route(City1,City2,Dist):-read(City1,X,Dist1),route(X,City2,Dist2),Dist=Dist1+Dist2,write('Distance bet.
'),write(City1),write(' and '),write(City2),write(' is '),write(Dist),nl.

Output:
Practical: 13

Aim: Write a PROLOG program based on list.


1. To reverse the list.
reverse([],[]).
reverse([H|T],R):-reverse(T,RT),append(RT,[H],R).
Output:

2. To add the member of a given list.


sum([],0).
sum([H|T],S):-sum(T,Temp),S is Temp+H.
Output:
Practical: 14

Aim: Write a PROLOG program to find the Greatest Common Divisor.


gcd(M,0,M).
gcd(M,N,Result):-N>0,Rem is M mod N,gcd(N,Rem,Result).

Output:
Practical: 15

Aim: Write a program to find simple interest with the help of prolog.
go:-write('Enter principal :'),read(P), write('Enter rate: '),read(R),write('Enter year: '),read(N),
I is P*R*N, S is I/100,
write('Simple Intres is='),write(S).

Output:
Practical: 16

Aim: Convert the following Prolog Predicates into Semantic Net


cat(tom).
cat(cat1).
mat(mat1).
sat_on(cat1,mat1).
bird(bird1).
caught(tom,bird1).
like(X,cream) :– cat(X).
mammal(X) :– cat(X).
has(X,fur) :– mammal(X).
animal(X) :– mammal(X).
animal(X) :– bird(X).
owns(john,tom).
is_coloured(tom,ginger).

Answer:

is intended to represent the data:


Tom is a cat.
Tom caught a bird.
Tom is owned by John.
Tom is ginger in colour.
Cats like cream.
The cat sat on the mat.
A cat is a mammal.
A bird is an animal.
All mammals are animals.
Mammals have fur.
Practical: 17

Aim: Write the Conceptual Dependency tor Following Statements


(a) John gives Mary a book
(b) John gave Mary the book yesterday

Answer:
Practical: 18

Aim:- Write a PROLOG/C program to solve the N-Queen Problem.

Program:-

#include<stdio.h>
#include<conio.h>
#include<math.h>
int a[30],count=0;
int place(int pos)
{
int i;
for(i=1;i<pos;i++)
{
if((a[i]==a[pos])||((abs(a[i]-a[pos])==abs(i-pos))))
return 0;
}
return 1;
}
void print_sol(int n)
{
int i,j;
count++;
printf("\n\nSolution #%d:\n",count);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(a[i]==j)
printf("Q\t");
else
printf("*\t");
}
printf("\n");
}
}
void queen(int n)
{
int k=1;
a[k]=0;
while(k!=0)
{
a[k]=a[k]+1; while((a[k]<=n)&&!
place(k))
a[k]++;
if(a[k]<=n)
{
if(k==n)
print_sol(n);
else
{
k++;
a[k]=0;
}
}
else
k--;
}
}
void main()
{
int i,n;
clrscr();
printf("Enter the number of Queens\n");
scanf("%d",&n);
queen(n);
printf("\nTotal solutions=%d",count);
getch();
}

Output:-
Practical: 19

Aim:- Write a PROLOG/C program to implement 8 – puzzle problem using A* Algorithm.

Program:-

#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
#include <conio.h>

#define DOWN 0
#define UP 1
#define LEFT 2
#define RIGHT 3
#define H2

struct elementstruct
{
int block[9];
char* str;
int pathcost;
int valid;
int totalcost;
elementstruct* next;
};

int heur(int block[]);


void prepend(elementstruct* newnode, elementstruct* oldnode, int operator1);
int goal(int* block);
int notonqueue(int block[]);
elementstruct* bestnodefromqueue();
void print_block(int* block);
int apply (int* newstate, int* oldstate, int op);
elementstruct* newelement();
int op(char);
char to_char(int i);

char rep[] = "dulr";


int notvalid1[4] = { 6, 0, 0, 2 };
int notvalid2[4] = { 7, 1, 3, 5 };
int notvalid3[4] = { 8, 2, 6, 8 };
int applyparam[4] = { +3, -3, -1, +1 };
int goal_block[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; //8 indicates no tile
int maxdepth;
elementstruct* top;

int main()
{
int block[9];
clrscr();
printf("\nThe Eight Puzzle!\n");
printf("\nPlease Enter the initial state of the game \n"
" [Represent tiles with numbers 1 to 8, and the blank space as 'x'.\n"
" Start writing them from left to right for each row. Start from the topmost row to the bottommost
row.\n"
" Your final string will look similar to this '1 4 2 3 x 6 7 8 5'.\n"
" Do not forget the spaces in between the characters]\n");
int i = 0;
while(i<9)
{
char chr;
chr = fgetc(stdin);
if (chr==32) continue;
if (chr=='x') block[i] = 8;
else if (chr >= '1' && chr <= '9') block[i] = chr - '1';
else { printf("Invalid Input. Example of valid input...2 1 3 4 7 5 6 8 x.", chr); return 1;
} i+
+;
}

fgetc(stdin); //flush out the end of line character


printf("\n Now Enter the Goal State in a similar way. (Typical. 1 2 3 4 5 6 7 8 x): ");
i = 0;
while(i<9)
{
char chr;
chr = fgetc(stdin);
if (chr==32) continue;
if (chr=='x') goal_block[i] = 8;
else if (chr >= '1' && chr <= '9') goal_block[i] = chr - '1';
else { printf("chr=%d. Invalid Input. Example of valid input...2 1 3 4 7 5 6 8 x.",(int) chr); return
1; }
i++;
}
printf("Enter the maximum depth you want to search (<25 is solved quickly): ");
scanf("%d", &maxdepth);

printf("\nWorking...");
top = newelement();
for(i=0; i<9; i++)
top->block[i] = block[i];
top->totalcost = heur(block);
elementstruct* newnode = newelement();
while (1)
{
elementstruct* node = bestnodefromqueue();
if (node == NULL)
{
printf("done!\n");
printf("There is no solution to this of less than %d depth.\n", maxdepth);
printf("Try increasing the depth by 5.\n");
printf("If there is no solution within 35-40 depth, the pattern is usually unsolvable.\n\n");
break;
}
else if (goal(node->block))
{
char chr[15];
printf("done. \nFound the solution of least number of steps (%d).", node->pathcost);
printf("\nWant a graphical display of each step? (Y/N)?");
scanf("%s", chr);
if(chr[0] =='n' || chr[0]=='N') {
printf("\n (Move Blank u=up, d=down, l=left, r=right)\n");
printf(node->str);
printf("\n");
break;
}
int block2[9];
for (i=0; i<node->pathcost; i++)
{
print_block(block);
apply(block2, block, op(node->str[i]));
for(int j=0; j<=8; j++)
block[j] = block2[j];
}
print_block(block);
printf("\nGraphical Display Complete.\nThe steps taken were: (Move blank u=up, d=down, l-left,
r=right)\n");
printf(node->str);
printf("\n");
break;
}
if (node->totalcost > maxdepth) continue;
for(i=0; i<=3; i++)
{
if (apply(newnode->block, node->block, i) == -1)
continue;
if (notonqueue(newnode->block))
{
prepend(newnode, node, i);
newnode = newelement();
if (newnode==NULL) { printf ("ERROR!! insufficient memory!! Try decreasing depth!");
return 1;
}
}
}
}
return 0;
}

int heur(int* block)


{
#ifdef H2
int to_return = 0;
for(int i=0; i<9; i++)
{
to_return += abs((i/3) - (block[i]/3));
to_return += abs((i%3) - (block[i]%3));
}
return to_return;
#else
int to_0return = 0;
for(int i=0; i<9; i++)
{
if (block[i] != i) to_return++;
}
return to_return;
#endif
}
void prepend(elementstruct* newnode, elementstruct* oldnode, int op)
{
newnode->next = top;
top = newnode;
strcpy(newnode->str, oldnode->str);
newnode->str[oldnode->pathcost] = rep[op];
newnode->str[oldnode->pathcost+1] = 0;
newnode->pathcost = oldnode->pathcost+1;
newnode->totalcost = newnode->pathcost + heur(newnode->block);
if (newnode->totalcost < oldnode->totalcost) newnode->totalcost = oldnode->totalcost;
}
int goal(int* block)
{
int* g_block = goal_block;
for(int i=0; i<9; i++)
if ((*(block++))!=(*(g_block++)))
return 0;
return 1;
}
int notonqueue(int* block)
{
int i,j;
elementstruct* t = top;
while (t!=NULL)
{
for(i=0; i<9; i++)
if (t->block[i] != block[i]) break;
if (i==9) return 0;
t = t->next;
}
return 1;
}
elementstruct* bestnodefromqueue()
{
elementstruct* t = top;
int min_totalpathcost = 1000;
int totalpathcost;
elementstruct* to_return = NULL;

while (t != NULL)
{
if (t->valid==1 && t->totalcost < min_totalpathcost)
{
min_totalpathcost = t->totalcost;
to_return = t;
}
t = t->next;
}
if (to_return != NULL) to_return->valid = 0;
return to_return;
}
int apply (int* newstate, int* oldstate, int op)
{
int j;
int blank;
for (j=0; j<9; j++)
if (oldstate[j]==8) { blank=j; break; }
if (blank==notvalid1[op] || blank==notvalid2[op] || blank==notvalid3[op])
return -1;
for (j=0; j<9; j++)
newstate[j] = oldstate[j];
newstate[blank] = newstate[blank+applyparam[op]];
newstate[blank+applyparam[op]] = 8;
return 1;
}
elementstruct* newelement()
{
elementstruct* t = new elementstruct;
if (t==NULL) return NULL;
t->valid = 1;
t->str = new char[maxdepth+1];
if (t->str ==NULL) return NULL;
t->str[0] = 0;
t->pathcost = t->totalcost = 0;
t->next = NULL;
return t;
}
void print_block(int* block)
{
printf("\n");
printf ("\n------");
printf ("\n|%c|%c|%c|", to_char(block[0]), to_char(block[1]), to_char(block[2]));
printf ("\n------");
printf ("\n|%c|%c|%c|", to_char(block[3]), to_char(block[4]), to_char(block[5]));
printf ("\n------");
printf ("\n|%c|%c|%c|", to_char(block[6]), to_char(block[7]), to_char(block[8]));
printf ("\n------");
}

char to_char(int i)
{
if (i>=0 &&i<=7) return i+'1';
else if (i==8) return 'x';
else
{
printf("ERROR in Program!"); return -1;
}
}
int op(char i)
{
switch (i)
{
case 'd': return 0;
case 'u': return 1;
case 'l': return 2;
case 'r': return 3;
default: printf("ERROR!"); return -1;
}
}

Output:-
PRACTICAL 20
Write a PROLOG/C program to implement an Expert System of your choice.

Program:-

domains
disease,indication = symbol
Patient,name = string

predicates
hypothesis(string,disease)
symptom(name,indication)
response(char)
go
clauses
go :-
write("What is the patient's name? "),
readln(Patient),
hypothesis(Patient,Disease),
write(Patient,"probably has ",Disease,"."),nl.

go :-
write("Sorry, I don't seem to be able to"),nl,
write("diagnose the disease."),nl.

symptom(Patient,fever) :-
write("Does ",Patient," have a fever (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,rash) :-
write("Does ",Patient," have a rash (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,headache) :-
write("Does ",Patient," have a headache (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,runny_nose) :-
write("Does ",Patient," have a runny_nose (y/n) ?"),
response(Reply),
Reply='y'.
symptom(Patient,conjunctivitis) :-
write("Does ",Patient," have a conjunctivitis (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,cough) :-
write("Does ",Patient," have a cough (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,body_ache) :-
write("Does ",Patient," have a body_ache (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,chills) :-
write("Does ",Patient," have a chills (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,sore_throat) :-
write("Does ",Patient," have a sore_throat (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,sneezing) :-
write("Does ",Patient," have a sneezing (y/n) ?"),
response(Reply),
Reply='y'.

symptom(Patient,swollen_glands) :-
write("Does ",Patient," have a swollen_glands (y/n) ?"),
response(Reply),
Reply='y'.

hypothesis(Patient,measles) :-
symptom(Patient,fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,runny_nose),
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,conjunctivitis),
symptom(Patient,chills),
symptom(Patient,sore_throat),
symptom(Patient,runny_nose),
symptom(Patient,cough).

hypothesis(Patient,common_cold) :-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,runny_nose),
symptom(Patient,chills).

hypothesis(Patient,mumps) :-
symptom(Patient,fever),
symptom(Patient,swollen_glands).

hypothesis(Patient,chicken_pox) :-
symptom(Patient,fever),
symptom(Patient,chills),
symptom(Patient,body_ache),
symptom(Patient,rash).

hypothesis(Patient,measles) :-
symptom(Patient,cough),
symptom(Patient,sneezing),
symptom(Patient,runny_nose).

response(Reply) :-
readchar(Reply),
write(Reply),nl.
Output :
PRACTICAL 21
Write a PROLOG/C program to solve Monkey-Banana problem.

Program:-

domains
state=state(symbol,symbol,symbol,sym
bol)
/*state=state(monkey horizontal monkey vertical, box location, has/has not banana) */

predicates
move(state,symbol,stat
e) canget(state)

clauses
move(state(middle,onbox,middle,hasn
ot),
grasp,state(middle,onbox,middle,has).
move(state(P,onfloor,P,hasnot),cli
mb, state(P,onbox,P,hasnot)).

move(state(P,onfloor,P,hasnot),p
ush, state(P1,onfloor,P1,hasnot)).

move(state(P1,onfloor,B,hasnot),w
alk, state(P2,onfloor,B,hasnot)).

canget(state(_,_,_,has))
:- write("get").

canget(State1) :-
move(State1,Move,State
2), canget(State2),
write(State2),nl.

goal
clearwindow,
canget(state(door,onfloor,window,hasn
ot)).
ARTIFICIAL INTELLIGENCE (3170716)

Output:-

MGITER/CE/2020-2021

You might also like