; ___________________________ ;| DEKLARACJE | ;|FUNKCJI ZADAJĄCYCH PYTANIA | ;|___________________________| (deffunction pytaj (?oco $?odpowiedzi) (printout t crlf crlf "**************************************************************************************" crlf) (printout t ?oco crlf) (printout t crlf crlf "**************************************************************************************" crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t " _|_| _| _| " crlf " _|_|_|_| _| " crlf " _| _| _| " crlf " _|_|_| _| _|PERT SYSTEM " crlf " " crlf) (printout t crlf crlf crlf ) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t $?odpowiedzi crlf) (printout t ": ") (bind ?odp (read)) (if (lexemep ?odp) then (bind ?odb (lowcase ?odp))) (while (not (member ?odp ?odpowiedzi)) do (printout t crlf crlf "**************************************************************************************" crlf) (printout t ?oco crlf) (printout t crlf crlf "**************************************************************************************" crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t " _|_| _| _| " crlf " _|_|_|_| _| " crlf " _| _| _| " crlf " _|_|_| _| _|PERT SYSTEM " crlf " " crlf) (printout t crlf crlf crlf ) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t $?odpowiedzi crlf) (printout t ": ") (bind ?odp (read))) ?odp ) (deffunction pytaj_o_liczbe (?co) (printout t ?co) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t ": ") (bind ?godz (read)) (printout t crlf) (while (or (not (integerp ?godz))(or (> ?godz 24)(< ?godz 7))) do (printout t ?co) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t ": ") (bind ?godz (read))) ?godz ) (deffunction drukuj (?e1 ?ke1 ?re1 ?e2 ?ke2 ?re2 ?e3 ?ke3 ?ke4 $?e5) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf "**************************************************************************************" crlf) (printout t "Proponuje, zebys zalozyl " ?ke1 " " ?re1 " " ?e1 " oraz " ?ke2 " " ?e2 crlf ) (if (neq ?re2 gladka) then (printout t "w "?re2 " " )) (printout t " do tego " ?ke3 " " ?e3 " i " ?ke4 " buty." crlf) (printout t "Pomysl jeszcze o dodatkach " $?e5 crlf) (printout t "**************************************************************************************" crlf crlf ) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) (printout t crlf crlf crlf crlf crlf crlf crlf crlf) 0 ) ; ___________________________ ;| REGOLY WNIOSOWANIA | ;|___________________________| (defrule init => (printout t crlf crlf "**************************************************************************************" crlf) (printout t "Witaj! Jestem ekspertem, ktory pomoze ci dobrac odpowiedni stroj na dzisiejsze wyjscie" crlf ) (printout t "Bede zadawal pytanie na ktore odpowiedz a ja zaproponuje najbardziej odpowiedni zestaw"crlf ) (printout t "Pytania z gwiazdka sa obowiazkowe pozostale mozesz pozostawic bez odwiedzi wpisujac x "crlf ) (printout t "**************************************************************************************" crlf crlf ) (assert(start)) ) (defrule start ?s <- (start) => (retract ?s) (assert ( godzina (pytaj_o_liczbe "O ktorej godzine jestes umowiony (podaj pelna godzine)*: " ))) ) (defrule rano ?r <- (godzina ?h) (and (test (<= ?h 11)) (test (>= ?h 6))) => (retract ?r) (assert (spotkanie rano)) ) (defrule popoludniu ?r <- (godzina ?h) (and (test (> ?h 11)) (test (<= ?h 17)))=> (retract ?r) (assert (spotkanie popoludniu)) ) (defrule wieczorem ?r <- (godzina ?h) (test(> ?h 17))=> (retract ?r) (assert (spotkanie wieczorem)) ) (defrule charakter ?r <- (spotkanie ?)=> (assert (charakter (pytaj "Spotkanie ma charakter okolicznosciowy,towarzyski czy sluzbowy?: " okolicznosciowy towarzyski sluzbowy x ))) ) (defrule charakter_nie_wiem ?r <- (charakter x)=> (bind ?odp1 (pytaj "Czy glownym tematem spotkania moze byc twoja praca*: " tak nie)) (bind ?odp2 (pytaj "Czy bedzie tam twoja rodzina lub najblizsi znajomi*: " tak nie )) (bind ?odp3 (pytaj "Czy bedziesz musial kupic prezent*: " tak nie)) (if (eq ?odp1 tak) then (retract ?r) (assert (charakter sluzbowy)) else (if (and (eq ?odp2 tak) (neq ?odp2 ?odp3)) then (retract ?r) (assert (charakter towarzyski)) else( if (and (eq ?odp3 tak) (eq ?odp2 ?odp3)) then (retract ?r) (assert (charakter okolicznosciowy)) ) ) ) ) (defrule rano_sluzbowy (spotkanie rano|popoludniu) (charakter sluzbowy|x) (not (nowa nie))=> (assert (nowa (pytaj "Czy spotykasz sie w sprawie nowej pracy?*: " tak nie))) ) (defrule ov (charakter x)=> (assert (obca tak)) ) (defrule nowa_praca ?s1 <- (spotkanie rano|popoludniu) ?s2 <- (charakter sluzbowy|x) ?s <- (nowa tak)=> (retract ?s ?s1 ?s2) (drukuj garnitur ciemnoszary gladki koszule biala "granatowa krate" krawat niebieski czarne wystarczy pioro) (assert (koniec tak)) ) (defrule z_kim (spotkanie ?) (charakter sluzbowy) (not (nowa tak))=> (assert (obca (pytaj "Czy na spotkaniu beda osoby ktorych nie znasz?*:" tak nie )))) (defrule obca_kobieta (obca tak)=> (assert (kobieta (pytaj "Czy obca osoba bedzie kobieta: " tak nie x))) ) (defrule kobieta_tak ?s1 <- (spotkanie rano|popoludniu) ?s2 <- (charakter sluzbowy) ?s3 <- (nowa nie) ?s4 <- (kobieta tak)=> (retract ?s1 ?s2 ?s3 ?s4) (drukuj garnitur brazowy gladki koszule fioletowobiala "kratke Vichy" krawat fiolkowy brazowe pioro) (assert (koniec tak)) ) (defrule kobieta_nie_rano ?s1 <- (spotkanie rano) ?s2 <- (charakter sluzbowy|x) ?s3 <- (nowa nie) ?s4 <- (kobieta nie|x)=> (retract ?s1 ?s2 ?s3 ?s4) (drukuj garnitur popielaty gladki koszule niebieska "kratke Vichy" "krawat klubowy" geranatowy brazowe pioro) (assert (koniec tak)) ) (defrule kobieta_nie ?s1 <- (spotkanie popoludniu) ?s2 <- (charakter sluzbowy|x) ?s3 <- (nowa nie) ?s4 <- (kobieta nie|x)=> (retract ?s1 ?s2 ?s3 ?s4) (drukuj garnitur szary gladki koszule niebieska "kratke Vichy" "krawat klubowy" geranatowy czarne pioro, zapalniczka) (assert (koniec tak)) ) (defrule wiczorem_sluzbowe ?s1 <- (spotkanie wieczorem) ?s2 <- (charakter sluzbowy) ?s3 <- (kobieta tak)=> (retract ?s1 ?s2 ?s3) (drukuj garnitur antracytowy gladki koszule czarna gladka krawat czerwony czarne zegarek,zapalniczka) (assert (koniec tak)) ) (defrule wiczorem_sluzbowe2 ?s1 <- (spotkanie wieczorem) ?s2 <- (charakter sluzbowy|x) ?s3 <- (kobieta nie|x)=> (retract ?s1 ?s2 ?s3 ) (drukuj garnitur antracytowy gladki koszule szara gladka krawat granatowy czarne zegarek) (assert (koniec tak)) ) (defrule obca_nie (not (stop tak)) ?s1 <- (obca nie) ?s2 <- (charakter sluzbowy) ?s3 <- (spotkanie ?) => (assert (nowa nie)) (assert (biuro (pytaj "Spotkanie ma miejsce w biurze*: " tak nie))) ) (defrule obca_biuro (not (stop tak)) ?s1 <- (obca nie) ?s2 <- (charakter sluzbowy) ?s3 <- (spotkanie ?) (biuro ?) => (assert (nowa nie)) (assert (wyklad (pytaj "Czy bedziesz cos prezentowal, wypowiadal sie podczas spotkania: " tak nie x) )) ) (defrule biuro_wyklad ?s1 <- (biuro tak) ?s2 <- (wyklad tak|x)=> (retract ?s1 ?s2) (drukuj garnitur ciemnoszary gladki koszule blekitna paski krawat czerwony czarne pioro,zegarek) (assert (koniec tak)) ) (defrule nie_biuro_wyklad ?s1 <- (biuro nie) ?s2 <- (wyklad tak|x)=> (retract ?s1 ?s2) (drukuj garnitur granatowy gladki koszule blekitna paski krawat czerwony czarne pioro,zegarek) (assert (koniec tak)) ) (defrule biuro_nie_wyklad ?s1 <- (biuro ?) ?s2 <- (wyklad nie)=> (retract ?s1 ?s2) (bind ?a (pytaj "Czy chcesz byc zauwazony na spotkaniu: " tak nie x )) (if (eq ?a tak) then (bind ?b czerwony) else (bind ?b niebieski)) (drukuj garnitur bezowy gladki koszule zolta krate krawat ?b czarne zegarek) (assert (koniec tak)) ) (defrule okolicznosciow ?f1 <- (spotkanie rano|popoludniu) ?f2 <- (charakter okolicznosciowy)=> (retract ?f1 ?f2) (assert (sl (pytaj "Czy jest to slub lub pogrzeb: " slub pogrzeb nie))) ) (defrule slub_tak ?f1 <- (sl slub)=> (retract ?f1) (bind ?kolor (pytaj "Zapytaj partnerke o kolor kreacji (czarna brazowa bezowa niebieska zielona czerwona zolta biala): " czarna brazowa bezowa niebieska biala zielona czerwona zolta x )) (if (member$ ?kolor (create$ brazowa bezowa zolta ) ) then (bind ?a1 bezowy) (bind ?a2 brazowe) (bind ?a3 czerwony) else (bind ?a1 szary) (bind ?a2 czarne) (bind ?a3 blekitny) ) (drukuj garnitur ?a1 "w paski" koszule biala gladka krawat ?a3 ?a2 zegarek) (assert (koniec tak)) ) (defrule nie_slub_pogrzeb ?s1 <- (sl nie)=> (retract ?s1) (assert (imieniny tak)) ) (defrule pogrzeb_tak ?s1 <- (sl pogrzeb)=> (retract ?s1 ) (drukuj garnitur czarny gladki koszule czarna gladka krawat czarny czarne zegarek) (assert (koniec tak)) ) (defrule okolicznosciowe ?f1 <- (spotkanie wieczorem) ?f2 <- (charakter okolicznosciowy)=> (retract ?f1 ) (assert (imieniny (pytaj "Czy sa to urodziny lub imieniny *: " tak nie))) ) (defrule czy_partnerka ?f <- (imieniny tak)=> (retract ?f) (assert (part (pytaj "Czy idziesz z osoba towarzyszaca*: "tak nie))) ) (defrule imieninu_urodziny ?s1 <- (part tak)=> (retract ?s1) (bind ?kolor (pytaj "Zapytaj partnerke o kolor kreacji (czarna brazowa bezowa niebieska zielona czerwona zolta biala): " czarna brazowa bezowa biala niebieska zielona czerwona zolta x )) (if (member$ ?kolor (create$ brazowa bezowa zolta ) ) then (bind ?a1 khaki) (bind ?a2 brazowe) else (bind ?a1 szary) (bind ?a2 czarne) ) (drukuj garnitur ?a1 gladki koszule fioletowobiala "kratke Vichy" krawat "fiolkowy we wzor kaszmirski" ?a2 zapalniczka) (assert (koniec tak)) ) (defrule imienine_sam (part nie)=> (assert (spotkanie rano)) (assert(charakter sluzbowy)) (assert(nowa nie)) (assert(kobieta tak)) ) (defrule nie_imieniny ?f1 <- (imieniny nie) ?f2 <- (charakter okolicznosciowy)=> (retract ?f1 ?f2) (assert (obca nie)) (assert (charakter sluzbowy)) (assert (spotkanie nie)) (assert (biuro nie)) ) (defrule towarzyski (spotkanie ?) (charakter towarzyski) => (assert (out (pytaj "Czy spotkanie odbywac sie bedzie na dworze?: "tak nie x))) ) (defrule ile_osob (spotkanie ?) (out ?)=> (assert (liczba (pytaj "Czy na spotkaniu bedzie wiecej niz 10 osob?:" tak nie x))) ) (defrule tow_rano_popoludniu ?a1 <- (spotkanie rano|popoludniu) ?a2 <- (out ?) ?a3 <- (liczba ?)=> (retract ?a1 ?a2 ?a3) (assert (spotkanie rano)) (assert (charakter sluzbowy)) ) (defrule kolacja ?w <- (spotkanie wieczorem) ?w2 <- (charakter towarzyski) ?w3 <- (out ?)=> (assert (kolacja (pytaj "Czy bedzie podawana kolacje*: " tak nie))) (assert (goo)) ) (defrule randka ?f <- (goo)=> (retract ?f) (assert (randka (pytaj "To jest randka?: " tak nie))) ) (defrule kolacja_nie (kolacja nie) (liczba ?) (randka ?)=> (assert (koncert (pytaj "Hmmm...moze idziesz na koncert*: "tak nie))) ) (defrule kolacja_tak ?s1 <- (kolacja tak) ?s2 <- (liczba ?) ?s3 <- (randka ?ax) ?s4 <- (out nie)=> (retract ?s1 ?s2 ?s3 ?s4) (if (neq ?ax tak) then (bind ?aa zapalniczka) else (bind ?aa prezerwatywy)) (bind ?co (pytaj "Idziesz do eleganckiej restauracji*?: " tak nie)) (if (eq ?co nie) then (drukuj dzinsy granatowe " " marynarke skorzana gladka tshirt bialy czarne ?aa) else (drukuj garnitur czarny gladki koszula biala gladka krawat czarny czarne szalik) ) (assert (koniec tak)) ) (defrule wiczor_out ?s1 <- (out tak) ?s2 <- (liczba nie) ?s3 <- (kolacja tak) ?s4 <- (randka nie) ?s5 <- (charakter towarzyski)=> (retract ?s1 ?s2 ?s3 ?s4) (assert (spotkanie wieczorem)) (assert (charakter sluzbowy)) (assert (kobieta nie)) ) (defrule nie_nie (randka nie) (gooo) ?a <- (charakter towarzyski) => (retract ?a) (assert (charakter okolicznosciowy)) (assert (spotkanie wieczorem)) ) (defrule wiczor_out_randka ?s1 <- (out tak) ?s2 <- (liczba nie) ?s3 <- (kolacja tak) ?s4 <- (randka tak) ?s5 <- (charakter towarzyski)=> (retract ?s1 ?s2 ?s3 ?s4) (assert (spotkanie wieczorem)) (assert (charakter sluzbowy)) (assert (kobieta tak)) ) (defrule teatr ?a1 <- (kolacja nie) ?a2 <- (koncert nie) ?a3 <- (liczba ?) ?a4 <- (randka ?ax) ?a5 <- (out nie)=> (if (neq ?ax tak) then (bind ?aa zapalniczka) else (bind ?aa prezerwatywy)) (bind ?co (pytaj "W taki razie teatr, kino*?: " kino teatr nie)) (if (eq ?co kino) then (drukuj dzinsy granatowe " " marynarke skorzana gladka tshirt bialy czarne ?aa) (assert (koniec tak)) else( if (eq ?co teatr) then (drukuj garnitur czarny gladki koszula biala gladka krawat czarny czarne szalik) (assert (koniec tak)) else (retract ?a1 ?a2 ?a3) (assert (gooo)) ) ) ) (defrule teatr2 ?a1 <- (kolacja nie) ?a2 <- (koncert nie) ?a3 <- (liczba ?) ?a4 <- (randka ?) ?a5 <- (out tak)=> (retract ?a1 ?a2 ?a4 ?a5 ?a3) (assert (gooo)) (assert (randka tak)) ) (defrule na_zew ?a1 <- (kolacja tak) ?a2 <- (liczba tak) ?a3 <- (randka tak) ?a4 <- (out tak)=> (retract ?a1 ?a2 ?a4 ) (assert (gooo)) ) (defrule randka_x (gooo) (randka tak)=> (drukuj garnitur antracytowy gladki koszule czarna gladka krawat czerwony czarne zegarek,zapalniczka) (assert (koniec tak)) ) (defrule koncert_tak ?s1 <- (koncert tak) ?s2 <- (randka ?ax)=> (retract ?s1 ?s2) (if (neq ?ax tak) then (bind ?aa fajek) else (bind ?aa prezerwatyw))=> (bind ?jaki (pytaj "Czy bedzie to koncert muzyki powaznej czy nowoczesnej ;) *: " powaznej nowoczesnej)) (if (eq ?jaki powaznej) then (drukuj frak czarny gladki koszule biala gladka muszka czarna czarne biale rekawiczki, bialy szalik) else ( drukuj 501'ki granatowe wytarte t-shirt bialy gladka sztruksowa jokejke sportowe dwie paczki ?aa)) ) (defrule koniec (koniec tak)=> (retract *) (printout t t "Mam nadzieje ze pomoglem . . ." crlf crlf) (release-mem