0
나는 사용자 입력에 따라 자극 상황을 결정하는 코드 조각을 썼다. 그러나 문제는 그것이 항상 동일한 출력을 제공하고 규칙에 따라 올바르지 않다는 것이다. 이 내 코드입니다 :이 간단한 코드가 Prolog에서 올바르게 실행되지 않는 이유는 무엇입니까?
start:- readenviroment(X),check(X,SS),environment(X,SS),write(SS).
readenviroment(X):-
write("What sort of environment is a trainee dealing with on the job?"),nl,
read(X).
environment(X,SS):-
visual(X,SS) ; verbal(X,SS).
visual(X,SS):-
((X == pictures ; X == illustrations ; X == photographs ; X== diagrams)->assert(yes(SS,cars))).
verbal(X,SS):-
((X == papers ; X == manuals ; X == documents ; X == textbooks)->assert(yes(SS,verbal))).
:- dynamic yes/2.
check(XX,SS):-
verify(XX,SS),!.
verify(XX,SS):-
yes(XX,SS)->true.
그리고 이것은 출력입니다 :
2 ?- start.
What sort of environment is a trainee dealing with on the job?
|: textbook.
verbal
true.
3 ?- start.
What sort of environment is a trainee dealing with on the job?
|: diagram.
false.
4 ?- start.
What sort of environment is a trainee dealing with on the job?
|: diagrams.
verbal
true.
이 두 가지 규칙에 따르면.
Rule 1:
if the environment is papers
or the environment is manuals
or the environment is documents
or the environment is textbooks
then stimulus_situation is verbal
Rule 2:
if the environment is pictures
if the environment is illustrations
if the environment is photographs
if the environment is diagrams
then stimulus_situation is visual
아무도 도와 줄 수 있습니까?! 또한 사전에 감사드립니다.
있습니다/이 규칙들이 인코딩 되었습니까? 그들은 코드에 나타나지 않는 것들을 참조합니다. –
@ScottHunter이 규칙은 시각적 및 언어 적 기능으로 인코딩됩니다. –
게시 된 코드의 내용은 논문, 매뉴얼, 문서, 교과서, 그림, 삽화, 사진 또는 다이어그램을 의미하지 않습니다. –