.


:




:

































 

 

 

 


2 (LABO2.PRO).




 

/* , */

/* . */

/* */

domains

conditions = bno*

rno,bno,fno =integer

category = symbol

 

database

/* p */

rule(rno,category,category,conditions)

cond(bno,symbol)

yes(bno)

no(bno)

topic(symbol)

 

predicates

/* p p */

do_expert_job

show_menu

do_consulting

process(integer)

info(category)

goes(category)

listopt

erase

clear

eval_reply(char)

/* p */

go(category)

check(rno,conditions)

inpo(rno,bno,string)

do_answer(rno,string,bno,integer)

 

goal

do_expert_job.

 

clauses

/* */

topic("dog").

topic("pp ").

topic("p ").

 

rule(1,"dog","pp ",[1]).

rule(2,"dog","p ",[2]).

rule(3,"pp "," ", [3,5,7]).

rule(4,"pp ","", [3,6,7]).

rule(5,"pp ","", [5,6,7,8]).

rule(6,"pp ","p ", [4,6,7]).

rule(7,"p ","p-", [3,5,6,7]).

rule(8,"p ","p p", [4,6]).

rule(9,"p ","", [4,5,7]).

rule(10,"p ","pp", [5,7,8]).

 

cond(1,"p p").

cond(2," p").

cond(3," 55 ").

cond(4," 75 ").

cond(5,"H ").

cond(6," ").

cond(7,"p pp").

cond(8," 5 ").

 

/* */

do_expert_job:-

makewindow(1,7,7,"DOG EXPERT SYSTEM",0,0,25,80),

show_menu,

nl,write("Press spase bar."),

readchar(_),

exit.

show_menu:-

write(" "),nl,

write("**********************************"),nl,

write("* DOG EXPERT *"),nl,

write("* *"),nl,

write("* 1. Consultation *"),nl,

write("* *"),nl,

write("* 2. Exit the system *"),nl,

write("* *"),nl,

write("**********************************"),nl,

write(" "),nl,

write("Please enter your choice: 1 or 2: "),nl,

readint(Choice),

process(Choice).

process(1):-do_consulting.

process(2):-removewindow, exit.

do_consulting:-goes(Mygoal),go(Mygoal),!.

do_consulting:-nl,write("Sorry, I can't help you."),

clear.

do_consulting.

goes(Mygoal):-clear,clearwindow,nl,nl,

write(" "),nl,

write(" WELCOME TO THE DOG EXPERT SYSTEM "),nl,

write(" "),nl,

write(" This is a dog identification system."),nl,

write(" To begin the process of choosing a "),nl,

write(" dog, please type in 'dog'. If you "),nl,

write(" wish to see the dog types, please "),nl,

write(" type in a question mark (?). "),nl,

write(" "),nl,

readln(Mygoal),

info(Mygoal),!.

info("?"):-clearwindow,

write("Reply from the KBS."),nl,

listopt,nl,

write("Please any key."),

readchar(_),

clearwindow,

exit.

info(X):- X >< "?".

listopt:-

write("The dog types are: "),nl,nl,

topic(Dog),

write(" ",Dog),nl,fail.

listopt.

inpo(Rno,Bno,Text):-

write("Question:-",Text,"? "),

makewindow(2,7,7,"Response",10,54,7,20),

write("Type 1 for 'yes': "),nl,

write("Type 2 for 'no': "),nl,

readint(Response),

clearwindow,

shiftwindow(1),

do_answer(Rno,Text,Bno,Response).

eval_reply('y'):-

write("I hope you have found this helpful!").

eval_reply('n'):-

write("I am sorry I can't help you!").

go(Mygoal):-

not(rule(_,Mygoal,_,_)),!,nl,

write("The dog you have indicated is a(n) ",Mygoal,"."),nl,

write(" Is a dog you would like to have (y/n)?"),nl,

readchar(R),

eval_reply(R).

 

/* */

go(Mygoal):-

rule(Rno,Mygoal,Ny,Cond),

check(Rno,Cond),

go(Ny).

check(Rno,[Bno|Rest]):-

yes(Bno),!,

check(Rno,Rest).

check(_,[Bno|_]):- no(Bno),!,fail.

check(Rno,[Bno|Rest]):-

cond(Bno,Text),

inpo(Rno,Bno,Text),

check(Rno,Rest).

check(_,[]).

do_answer(_,_,_,0):- exit.

do_answer(_,_,Bno,1):-

assert(yes(Bno)),

shiftwindow(1),

write(yes),nl.

do_answer(_,_,Bno,2):-

assert(no(Bno)),

write(no),nl,

fail.

erase:- retract(_),fail.

erase.

clear:-

retract(yes(_)),

retract(no(_)),

fail,!.

clear.

/* pp */

2





:


: 2017-03-18; !; : 304 |


:

:

,
==> ...

1735 - | 1604 -


© 2015-2024 lektsii.org - -

: 0.016 .