【发布时间】:2021-08-06 23:25:18
【问题描述】:
我想请问您能否建议我如何创建条件或重做代码。我需要程序的输出来检测 covid19 的症状。如果我在程序中的十个症状中至少有 3 次标记为“是”,则输出将是“您有 covid19 症状”。如果“是”少于 3 次,则输出将是“您没有 covid19 症状”。 谢谢
start :- x(Disease), write('the verdict is : '), write(Disease),nl, undo.
x(symptoms) :- symptoms,!.
x(withoutsymptoms). /* without symptoms */
symptoms :- verify(conjunctivitis),
verify(sore_throat),
verify(fatigure),
verify(shake),
verify(diarrhea),
verify(runny_nose),
verify(cold),
verify(muscle_pain),
verify(chest_pressure),
verify(loss_of_taste),
verify(fever).
ask(Question) :-
write('How are you? '),
write(Question),
write('? '),
read(Response),
nl,
( (Response == yes ; Response == yes)
->
assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
verify(S) :-
(yes(S)
->
true ;
(no(S)
->
fail ;
ask(S))).
undo :- retract(yes(_)),fail.
undo :- retract(no(_)),fail.
undo.
【问题讨论】:
标签: prolog detection expert-system