1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
:-dynamic(known/3).
liste_animaux([tigre,guepard,girafe,zebre,autruche,pingouin,aigle]).
animal(X):-liste_animaux(L),member(P,L),T=..[P,X],T,write('je pense que '),write(' est un '),write(P).
/*
1. SI (animal a poils) ALORS (animal est mammifère)
2. SI (animal donne lait) ALORS (animal est mammifère)
3. SI (animal mange viande) ALORS (animal est carnivore)
4. SI (animal a dents pointus) ET (animal a griffes) ET (animal a yeux vers avant) ALORS (animal est carnivore)
5. SI (animal est mammifère) ET (animal a sabots) ALORS (animal est ongulé)
6. SI (animal est mammifère) ET (animal n'est pas carnivore) ALORS (animal est ongulé)
7. SI (animal est mammifère) ET (animal est carnivore) ET (animal est couleur brune) ET (animal a tâches sombres) ALORS (animal est guépard)
8. SI (animal est mammifère) ET (animal est carnivore) ET (animal est couleur brune) ET (animal a raies noires) ALORS (animal est tigre)
9. SI (animal est ongulé) ET (animal a long cou) ET (animal a longues pattes) ET (animal a tâches sombres) ALORS (animal est girafe)
10. SI (animal est ongulé) ET (animal a raies noires) ALORS (animal est zèbre)
11. SI (animal a plumes) ALORS (animal est oiseau)
12. SI (animal vole) ET (animal pond œufs) ALORS (animal est oiseau)
13. SI (animal est oiseau) ET (animal ne vole pas) ET (animal a long cou) ET (animal a longues pattes) ET (animal est noir et blanc) ALORS (animal est autruche)
14. SI (animal est oiseau) ET (animal ne vole pas) ET (animal nage) ET (animal est noir et blanc) ALORS (animal est pingouin)
15. SI (animal est oiseau) ET (animal est carnivore) ALORS (animal est aigle)
*/
%1.
est_un(X,mammifere) :- corps_couvert_de(X,poils).
%2.
est_un(X,mammifere) :- nourriture_petit(X,lait).
%3.
est_un(X,carnivore) :- nourriture(X,viande).
%4.
est_un(X,carnivore) :- forme_des_dents(X,pointue),extremites_des_pattes(X,griffes),direction_des_yeux(X,en_avant).
%5.
est_un(X,ongule) :- est_un(X,mammifere), extremites_des_pattes(X,sabots).
%6.
est_un(X,ongule) :- est_un(X,mammifere),not(est_un(X,carnivore)).
%7.
guepard(X) :- est_un(X,mammifere),est_un(X,carnivore),couleur(X,brune),robe_avec(X,taches_sombres).
%8.
tigre(X) :- est_un(X,mammifere),est_un(X,carnivore),couleur(X,brune),robe_avec(X,raies_noires).
%9.
girafe(X) :- est_un(X,ongule),nature_du_cou(X,long),nature_des_pattes(X,longues),robe_avec(X,taches_sombres).
%10.
zebre(X) :- est_un(X,ongule),robe_avec(X,raies_noires).
%11.
ligne 47 est_un(X,oiseau) :- corps_couvert_de(X,plumes).
%12.
est_un(X,oiseau) :- locomotion(X,vole),reproduction(X,pond_des_oeufs).
%13.
autruche(X) :- est_un(X,oiseau),not(locomotion(X,vole)),nature_du_cou(X,long),nature_des_pattes(X,longues),couleur(X,noir_et_blanc).
%14.
pingouin(X) :- est_un(X,oiseau),not(locomotion(X,vole)),locomotion(X,nage),couleur(X,noir_et_blanc).
%15.
aigle(X) :- est_un(X,oiseau),est_un(X,carnivore).
ligne 58est_un(X,Y) :- ask(est_un,X,Y).
corps_couvert_de(X,Y) :- ask(corps_couvert_de,X,Y).
nourriture_petit(X,Y) :- ask(nourriture_petit,X,Y).
forme_des_dents(X,Y) :- ask(forme_des_dents,X,Y).
extremites_des_pattes(X,Y) :- ask(extremites_des_pattes,X,Y).
direction_des_yeux(X,Y) :- ask(direction_des_yeux,X,Y).
couleur(X,brune,Y) :- ask(couleur,X,Y).
robe_avec(X,Y):- ask(robe_avec,X,Y).
nature_du_cou(X,Y) :- ask(nature_du_cou,X,Y).
nature_des_pattes(X,Y) :- ask(nature_des_pattes,X,Y).
locomotion(X,Y) :- ask(locomotion,X,Y).
reproduction(X,Y) :- ask(reproduction,X,Y).
ask(U,X,Y):-known(U,X,Y).
ask(est_un,X,Y) :- not(known(est_un,X,Y)),write('animal est un '), writeln(' mammifere/carnivore/ongule/oiseau/'), read(Y),assert(known(est_un,X,Y)).
ask(corps_couvert_de,X,Y) :- not(known(corps_couvert_de,X,Y)),write('son corp est couvert de '), writeln(' plumes/poils'), read(Y),assert(known(corps_couvert_de,X,Y)).
ask(nourriture_petit,X,Y) :- not(known(nourriture_petit,X,Y)),write('la nourriture du petit est '), writeln(' lait'), read(Y),assert(known(nourriture_petit,X,Y)).
ask(forme_des_dents,X,Y) :- not(known(forme_des_dents,X,Y)),write('la forme de ses dents est '), writeln(' pointue'), read(Y),assert(known(forme_des_dents,X,Y)).
ask(extremites_des_pattes,X,Y) :- not(known(extremites_des_pattes,X,Y)),write('extremité de ses pattes '), writeln(' sabots/griffes'), read(Y),assert(known(extremites_des_pattes,X,Y)).
ask(direction_des_yeux,X,Y) :- not(known(direction_des_yeux,X,Y)),write('animal a les yeux '), writeln(' en_avant'), read(Y),assert(known(direction_des_yeux,X,Y)).
ask(couleur,X,Y) :- not(known(couleur,X,Y)),write('animal est de couleur '), writeln(' brune/noir_et_blanc'), read(Y),assert(known(couleur,X,Y)).
ask(robe_avec,X,Y) :- not(known(robe_avec,X,Y)),write('animal a une robe avec '), writeln(' raies_noires/taches_sombres'), read(Y),assert(known(robe_avec,X,Y)).
ask(nature_du_cou,X,Y) :- not(known(nature_du_cou,X,Y)),write('animal a un cou '), writeln(' long'), read(Y),assert(known(nature_du_cou,X,Y)).
ask(nature_des_pattes,X,Y) :- not(known(nature_des_pattes,X,Y)),write('animal a des pattes '), writeln(' longues'), read(Y),assert(known(nature_des_pattes,X,Y)).
ask(locomotion,X,Y) :- not(known(locomotion,X,Y)),write('animal '), writeln(' vole/nage'), read(Y),assert(known(locomotion,X,Y)).
ask(reproduction,X,Y) :- not(known(reproduction,X,Y)),write('animal '), writeln(' pond_des_oeufs'), read(Y),assert(known(reproduction,X,Y)). |
Partager