Advertisement
Guest User

Untitled

a guest
May 24th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;****************
  2. ;;* DEFFUNCTIONS *
  3. ;;****************
  4.  
  5. (deffunction ask-question (?question $?allowed-values)
  6.    (printout t ?question)
  7.    (bind ?answer (read))
  8.    (if (lexemep ?answer)
  9.        then (bind ?answer (lowcase ?answer)))
  10.    (while (not (member ?answer ?allowed-values)) do
  11.       (printout t ?question)
  12.       (bind ?answer (read))
  13.       (if (lexemep ?answer)
  14.           then (bind ?answer (lowcase ?answer))))
  15.    ?answer)
  16.  
  17. (deffunction yes-or-no-p (?question)
  18.    (bind ?response (ask-question ?question tak nie t n))
  19.    (if (or (eq ?response tak) (eq ?response t))
  20.        then yes
  21.        else no))
  22.  
  23.  
  24.  
  25.  
  26. ;;;***************
  27. ;;;* QUERY RULES *
  28. ;;;***************
  29.  
  30. (defrule determine-peaceful-music ""
  31.    (not (peaceful-music ?))
  32.    (not (proposition ?))
  33.    =>
  34.    (assert (peaceful-music (yes-or-no-p "Czy lubisz sluchac spokojnej muzyki (tak/nie)? "))))
  35.    
  36. (defrule determine-fingerstyle-music ""
  37.    (peaceful-music yes)
  38.    (not (proposition ?))
  39.    =>
  40.    (assert (fingerstyle-music (yes-or-no-p "Podoba Ci sie styl grania na gitarze o nazwie Fingerstyle (tak/nie)? "))))
  41.    
  42. (defrule determine-rock-music ""
  43.    (peaceful-music no)
  44.    (not (proposition ?))  
  45.    =>
  46.    (assert (rock-music (yes-or-no-p "Czy lubisz sluchac rocka (tak/nie)? "))))
  47.  
  48. (defrule determine-fingerstyle ""
  49.    (fingerstyle-music yes)
  50.    (not (proposition ?))  
  51.    =>
  52.    (assert (fingerstyle-favorite (ask-question "Wolisz Romance de Amour czy Noche Acosador (romance/noche)? "
  53.                     romance noche))))
  54.  
  55. (defrule determine-standard-playing ""
  56.    (fingerstyle-music no)
  57.    (not (proposition ?))
  58.    =>
  59.    (assert (standard-playing (ask-question "Wolisz grac na gitarze piosenki przy ognisku czy zajac sie gra bardziej na powaznie (ognisko/powaga)? "
  60.                     ognisko powaga))))
  61.  
  62. (defrule determine-rock-type ""
  63.    (rock-music yes)
  64.    (not (proposition ?))  
  65.    =>
  66.    (assert (rock-type (ask-question "Jakiego rocka lubisz sluchac? (lekki/sredni/ciezki)? "
  67.                     lekki sredni ciezki))))
  68.    
  69. (defrule determine-metal-music ""
  70.    (rock-music no)
  71.    (not (proposition ?))
  72.    =>
  73.    (assert (metal-music (yes-or-no-p "Czy lubisz sluchac metalu (tak/nie)? "))))
  74.  
  75. (defrule determine-metal-type ""
  76.    (metal-music yes)
  77.    (not (proposition ?))  
  78.    =>
  79.    (assert (metal-type (ask-question "Ktorego z tych zespolu metalowego lubisz sluchac najbardziej? (metallica/slipknot/marilynmanson)? "
  80.                     metallica slipknot marilynmanson))))
  81.  
  82.  
  83. ;;;****************
  84. ;;;* PROPOSITIONS RULES *
  85. ;;;****************
  86.    
  87. (defrule fingerstyle-romance-conclusions ""
  88.    (fingerstyle-favorite romance)
  89.    (not (proposition ?))
  90.    =>
  91.    (assert (proposition "Gitara klasyczna!")))
  92.    
  93. (defrule fingerstyle-noche-conclusions ""
  94.    (fingerstyle-favorite noche)
  95.    (not (proposition ?))
  96.    =>
  97.    (assert (proposition "Gitara akustyczna")))
  98.  
  99. (defrule standard-playing-ognisko-conclusions ""
  100.    (standard-playing ognisko)
  101.    (not (proposition ?))
  102.    =>
  103.    (assert (proposition "Gitara klasyczna")))
  104.  
  105. (defrule standard-playing-powaga-conclusions ""
  106.    (standard-playing powaga)
  107.    (not (proposition ?))
  108.    =>
  109.    (assert (proposition "Gitara akustyczna")))
  110.  
  111. (defrule rock-type-lekki-conclusions ""
  112.    (rock-type lekki)
  113.    (not (proposition ?))
  114.    =>
  115.    (assert (proposition "Gitara elektryczna, najlepiej z trzema przetwornikami typu Single!")))
  116.  
  117. (defrule rock-type-sredni-conclusions ""
  118.    (rock-type lekki)
  119.    (not (proposition ?))
  120.    =>
  121.    (assert (proposition "Gitara elektryczna, najlepiej z dwoma przetwornikami typu Single (neck i middle) oraz jednym przetwornikiem typu Humbucker (bridge)!")))
  122.  
  123. (defrule rock-type-ciezki-conclusions ""
  124.    (rock-type ciezki)
  125.    (not (proposition ?))
  126.    =>
  127.    (assert (proposition "Gitara elektryczna, najlepiej z dwoma przetwornikami typu Humbucker (bridge i neck)!")))
  128.  
  129. (defrule metal-type-metallica-conclusions ""
  130.    (metal-type metallica)
  131.    (not (proposition ?))
  132.    =>
  133.    (assert (proposition "Gitara elektryczna, najlepiej ESP LTD z dwoma przetwornikami typu Humbucker, modele EMG81 (bridge) oraz EMG60 (neck)!")))
  134.  
  135. (defrule metal-type-slipknot-conclusions ""
  136.    (metal-type slipknot)
  137.    (not (proposition ?))
  138.    =>
  139.    (assert (proposition "Gitara elektryczna, najlepiej Fender Telecaster z przetwornikami typu Humbucker firmy EMG lub B.C. Rich z Seymour Duncanami!")))
  140.  
  141. (defrule metal-type-marilynmanson-conclusions ""
  142.    (metal-type marilynmanson)
  143.    (not (proposition ?))
  144.    =>
  145.    (assert (proposition "Gitara elektryczna, najlepiej Gibson Thunderbird na fabrycznych przetwornikach typu Humbucker lub Fender Telecaster sygnowany przez John'a 5!")))
  146.  
  147. (defrule no-propositions ""
  148.   (declare (salience -10))
  149.   (not (proposition ?))
  150.   =>
  151.   (assert (proposition "Nie kupuj gitary :-)")))
  152.  
  153.  
  154.  
  155.  
  156. ;;;********************************
  157. ;;;* STARTUP AND CONCLUSION RULES *
  158. ;;;********************************
  159.  
  160. (defrule system-banner ""
  161.   (declare (salience 10))
  162.   =>
  163.   (printout t crlf crlf)
  164.   (printout t "System doradzania do wyboru rodzaju gitary")
  165.   (printout t crlf crlf))
  166.  
  167. (defrule print-proposition ""
  168.   (declare (salience 10))
  169.   (proposition ?item)
  170.   =>
  171.   (printout t crlf crlf)
  172.   (printout t "Proponowana rodzaj gitary:")
  173.   (printout t crlf crlf)
  174.   (format t " %s%n%n%n" ?item))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement