Descrizione del progetto
And there's a knowledge base.
The question is, help transfer the program to the Visual Prolog console. I'll pay a coin!
Program code on Turbo Prolog and knowledge base.
[HIGHLIGHT="prolog"]
DOMAINS
I=integer
S=stringing
C=char
Li=i*
Database - knowledge
Cond(i,s)
Rule(s,li)
DATABASE - dialog
Cond_is(i,c)
PREDICATES
Start starting.
Cars
Check(li)
Test_cond(i)
Update
Add_cond(li)
Print_cond(i,li,li)
Read_cond(c,li,li)
Ex_cond(i,li,li,i)
Wr_cond(c,i,li,li)
New_cond(i,li,li)
Read_true_char(c)
Test(c,c)
Clauses
Start:
consult("exp.DDB",knowledge),
nl,nl,nl,nl,write("*** Help cars ****"),nl,
write("Pomochnik obnaryzgenia nepoladki"),nl.
write("Ovetite na voprosi, a ya ykazgy ploblemy"),nl,
cars
retractall(_,dialog),
retractall(_,knowledge)
nl,nl,write (Mogy snova vam pomoch? (1 - da, 2 - net)",
read_true_char(C),
C='1',!, start.
Start:
nl,nl,write("****************** Vsego dobrogo!) Do novih vstrech",
readchar(_).
Cars:-
rule(X,L),
check(L),
nl,nl,write("********************* Expert sistema Help Cars"),nl,
write("* Opredelila nepoladku:",X),nl.
write("ya prav? (1 - da, 2 - net)",
read_true_char(C), C='1'!
Cars:-
nl,nl,write("************************ Ya ne znayu, chto eto za polomka"),nl,
nl,write("Davaite dobavim ee' v bazu znani"),nl,
update.
Update:-
nl,write("Vvedie nepoladky:"),
readln(S),
add_cond(L),
assert(rule(S,L),knowledge),
save("exp.ddb",knowledge).
Add_cond(L):-
cond_is(_,'1'),!
nl,nl,write("*************************** O nepoladki izvestni, prichina:"),
print_cond(1,[],L1),
nl,write("Izvestno li o nem esho chto-nibud?? (1 - da, 2 - net)",
read_true_char(C),
read_cond(C,L1,L).
Add_cond(L):-
read_cond('1',[],L).
Print_cond(H,L,L):-
not(cond(H,_),!
Print_cond(H,L,L1):-
cond_is(H,'1'),!
cond(H,T),
H1=H+1,
nl,write(T),
print_cond(H1,[H|L],L1).
Print_cond(H,L,L1):-
H1=H+1,
print_cond(H1,L,L1).
Read_cond('1',L,L2):-
ex_cond(1,L,L1,N),
new_cond(N,L1,L2)!
Read_cond(_,L,L):-!
Ex_cond(N,L,L,N):
not(cond(N,_),!
Ex_cond(N,L,L1,N2):-
cond_is(N,_),!
N1 = N+1,
ex_cond(N1,L,L1,N2).
Ex_cond(N,L,L1,N2):-
cond(N,S),
nl,write("Y nee",S"?? (1 - da, 2 - net)",
read_true_char(A),
wr_cond(A,N,L,L2),
N1 = N+1,
ex_cond(N1,L2,L1,N2).
Wr_cond('1',N,L,[N|L]):-!
Wr_cond('2',_,L,L):-!
New_cond(N,L,L1):-
nl,write("Est' esho prichini? (1 - da, 2 - net)",
read_true_char(A),
A='1'!,
nl,write("Ukaghite new svoistvo, polomki"),nl,
nl,write("New otlichintelinoe cvoistvo nepoladki '"), readln(S),
assertz(cond(N,S),
N1 = N+1,
new_cond(N1,[N|L],L1).
New_cond(_,L,L).
Check([H|T]):-
test_cond(H),
check(T).
Check([]).
Test_cond(H):-
cond_is(H,'1'),!
Test_cond(H):-
cond_is(H,'2'),!
fail.
test_cond(H):-
cond(H,S),
nl,nl,write("Y vas",S"??? (1 - da, 2 - net)",
read_true_char(A),
assert(cond_is(H,A),
test_cond(H).
Read_true_char(C):-
readchar(C1),
test(C1,C).
Test(C,C):-
'1'