Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :- consult('getyesno.pl').
- % Main control procedures
- start :-
- write('Ten program sprobuje zgadnac postac z Dragon Ball, o ktorej pomyslisz.'),nl,
- write('Na pytania odpowiadaj tylko T(Tak) lub N(Nie).'),nl,
- clear_stored_answers,
- try_all_possibilities.
- try_all_possibilities :- % Backtrack through all possibilities...
- postac(D),
- explain(D),
- fail.
- try_all_possibilities. % ...then succeed with no further action.
- % Diagnostic knowledge base
- % (conditions under which to give each diagnosis)
- postac(bulma) :-
- user_says(kobieta, yes),
- user_says(geniusz, yes).
- postac(c18) :-
- user_says(kobieta, yes),
- user_says(geniusz, no),
- user_says(blondynka, yes).
- postac(chi) :-
- user_says(kobieta, yes),
- user_says(geniusz, no),
- user_says(blondynka, no),
- user_says(ojciec, no).
- postac(videl) :-
- user_says(kobieta, yes),
- user_says(geniusz, no),
- user_says(blondynka, no),
- user_says(ojciec, yes).
- postac(goku) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, no),
- user_says(blizna, no),
- user_says(wlosy, yes),
- user_says(nerwy, no),
- user_says(madry, no).
- postac(gohan) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, no),
- user_says(blizna, no),
- user_says(wlosy, yes),
- user_says(nerwy, no),
- user_says(madry, yes).
- postac(vegeta) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, no),
- user_says(blizna, no),
- user_says(wlosy, yes),
- user_says(nerwy, yes).
- postac(raditz) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, no),
- user_says(blizna, no),
- user_says(wlosy, no).
- postac(c17) :-
- user_says(kobieta, no),
- user_says(ziemianin, yes),
- user_says(lysy, no),
- user_says(blizna, no),
- user_says(wlosy, no).
- postac(yamcha) :-
- user_says(kobieta, no),
- user_says(ziemianin, yes),
- user_says(lysy, no),
- user_says(blizna, yes).
- postac(tenshinhan) :-
- user_says(kobieta, no),
- user_says(ziemianin, yes),
- user_says(lysy, yes),
- user_says(oko, yes).
- postac(roshi) :-
- user_says(kobieta, no),
- user_says(ziemianin, yes),
- user_says(lysy, yes),
- user_says(oko, no),
- user_says(okulary, yes).
- postac(kuririn) :-
- user_says(kobieta, no),
- user_says(ziemianin, yes),
- user_says(lysy, yes),
- user_says(oko, no),
- user_says(okulary, no).
- postac(freeza) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, yes),
- user_says(armia, yes).
- postac(piccolo) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, yes),
- user_says(armia, no),
- user_says(zielony, yes),
- user_says(ogon, no).
- postac(cell) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, yes),
- user_says(armia, no),
- user_says(zielony, yes),
- user_says(ogon, yes).
- postac(buu) :-
- user_says(kobieta, no),
- user_says(ziemianin, no),
- user_says(lysy, yes),
- user_says(armia, no),
- user_says(zielony, no).
- %
- % Case knowledge base
- % (information supplied by the user during the consultation)
- %
- :- dynamic(stored_answer/2).
- % (Clauses get added as user answers questions.)
- %
- % Procedure to get rid of the stored answers
- % without abolishing the dynamic declaration
- %
- clear_stored_answers :- retract(stored_answer(_,_)),fail.
- clear_stored_answers.
- %
- % Procedure to retrieve the user's answer to each question when needed,
- % or ask the question if it has not already been asked
- %
- user_says(Q,A) :- stored_answer(Q,A).
- user_says(Q,A) :- \+ stored_answer(Q,_),
- nl,nl,
- ask_question(Q),
- get_yes_or_no(Response),
- asserta(stored_answer(Q,Response)),
- Response = A.
- %
- % Texts of the questions
- %
- ask_question(kobieta) :-
- write('Czy twoja postac jest kobieta?'),nl.
- ask_question(geniusz) :-
- write('Czy twoja postac jest geniuszem?'),nl.
- ask_question(blondynka) :-
- write('Czy twoja postac jest blondynka?'),nl.
- ask_question(ojciec) :-
- write('Czy twoja postac ma slawnego ojca?'),nl.
- ask_question(ziemianin) :-
- write('Czy twoja postac jest ziemianinem?'),nl.
- ask_question(lysy) :-
- write('Czy twoja postac jest lysa?'),nl.
- ask_question(blizna) :-
- write('Czy twoja postac ma na twarzy blizne?'),nl.
- ask_question(wlosy) :-
- write('Czy twoja postac potrafi zmieniac kolor swoich wlosow?'),nl.
- ask_question(nerwy) :-
- write('Czy twoja postac latwo sie denerwuje?'),nl.
- ask_question(madry) :-
- write('Czy twoja postac jest madra?'),nl.
- ask_question(oko) :-
- write('Czy twoja postac ma trzecie oko?'),nl.
- ask_question(okulary) :-
- write('Czy twoja postac nosi okulary?'),nl.
- ask_question(armia) :-
- write('Czy twoja postac dowodzi armia?'),nl.
- ask_question(zielony) :-
- write('Czy twoja postac jest zielona?'),nl.
- ask_question(ogon) :-
- write('Czy twoja postac ma ogon?'),nl.
- %
- % Explanations for the various diagnoses
- %
- explain(bulma) :-
- nl,
- write('Bulma'),nl.
- explain(c18) :-
- nl,
- write('C18'),nl.
- explain(chi) :-
- nl,
- write('Chi Chi'),nl.
- explain(videl) :-
- nl,
- write('Videl'),nl.
- explain(goku) :-
- nl,
- write('Son Goku'),nl.
- explain(gohan) :-
- nl,
- write('Gohan'),nl.
- explain(vegeta) :-
- nl,
- write('Vegeta'),nl.
- explain(raditz) :-
- nl,
- write('Raditz'),nl.
- explain(c17) :-
- nl,
- write('C17'),nl.
- explain(yamcha) :-
- nl,
- write('Yamcha'),nl.
- explain(tenshinhan) :-
- nl,
- write('Tenshinhan'),nl.
- explain(roshi) :-
- nl,
- write('Muten Roshi').
- explain(kuririn) :-
- nl,
- write('Kuririn'),nl.
- explain(freeza) :-
- nl,
- write('Freeza'),nl.
- explain(piccolo) :-
- nl,
- write('Piccolo'),nl.
- explain(cell) :-
- nl,
- write('Cell'),nl.
- explain(buu) :-
- nl,
- write('Majin Buu'),nl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement