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これらのルールは、視覚的および口頭の機能でエンコードされています。 –
投稿されたコードの中には、論文、マニュアル、文書、教科書、写真、イラスト、写真、図などはありません。 –