Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Conditions
- cond(1, "Can swim"). % mojet plavat
- cond(2, "Has strips"). % imeet poloski
- cond(3, "A bird"). % ptica
- cond(4, "Can fly"). % mojet letat
- cond(5, "Mammal"). % mlekopitaushee
- cond(6, "Has horns"). % imeet roga
- cond(7, "Has hooves"). % imeet kopita
- cond(8, "Predator"). % hishnik
- cond(9, "Has feathers"). % imeet perja
- cond(10, "Laying eggs"). % otkladivaet yajza
- cond(11, "Herbivore"). % travojadnoe
- cond(12, "Has wool"). % imeet sherst
- cond(13, "Has spots"). % imeet pyatna
- cond(14, "Has tentacles"). % imeet shupalza
- cond(15, "Has claws"). % imeet kogti
- cond(16, "Has long neck"). % imeet dlinnuyu sheyu
- cond(17, "Has long legs"). % imeet dlinnie nogi
- membere(X, [X|_]).
- membere(X, [_|Tail]) :-
- membere(X,Tail).
- check(2,I,L,L).
- check(1,I,L,[I|L]).
- writeans(1) :-
- write("+"),
- write(nl).
- writeans(2) :-
- write("-"),
- write(nl).
- check_cond(17,L,L).
- check_cond(I,L,A) :-
- cond(I,S),
- write(I + ". " + S + "? "),
- read(C, I + ". " + S + "? "),
- check(C, I, L, L1),
- writeans(C),
- X is I + 1,
- check_cond(X, L1, A).
- eqlist([], L).
- eqlist([H|T], L):-
- membere(H, L),
- eqlist(T, L).
- update:-
- write("\nEnter animal name"),
- read(S, "Enter animal name: "),
- write("\nEnter rules of new animal"),
- read(L, "Enter rules of new animal: "),
- write("\nAdded new animal: "),
- write(S),
- assert_in(rule(S,L)).
- animals :-
- write("\nChoose rules of animal:\n"),
- L is [],
- check_cond(1, L, A),
- rule(S, L1),
- eqlist(L1, A),
- eqlist(A, L1),
- write("I think it is "),
- write(S),
- write(nl).
- animals :-
- write("\nThere is no that animal.").
- write("\nUse 'Add new animal' action to add new animal").
- menu :-
- write("Menu:\n1. Add new animal\n"),
- write("2. Check animal\n"),
- write("3. Exit\n"),
- read(C),
- menu_point(C), menu.
- menu_point(1) :- update.
- menu_point(2) :- animals.
- ?- menu.
- % Rules
- rule("cheetah", [5, 8, 12, 13, 15]).
- rule("tiger", [2, 5, 8, 11, 15]).
- rule("giraffe", [5, 7, 11, 12, 13, 16, 17]).
- rule("penguin", [1, 3, 5, 8, 9, 10, 15]).
- rule("octopus", [1, 8, 10, 14]).
- rule("cat",[1,2,3]) .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement