Aguezz

Kuliah - Sistem Cerdas - UTS

May 8th, 2022 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. (deffunction input (?question)
  2. (printout t ?question)
  3. (bind ?answer (read))
  4. ?answer
  5. )
  6.  
  7. (defrule get-companion
  8. =>
  9. (printout t crlf)
  10. (printout t "-----------------------------------------------------------------------------" crlf)
  11. (printout t "-------------------- WELCOME TO THE MOVIE RECOMMENDATION --------------------" crlf)
  12. (printout t "-----------------------------------------------------------------------------" crlf)
  13. (printout t crlf)
  14. (assert (companion
  15. (input "Who are you going to watch with? (family/partner/alone): ")
  16. ))
  17. )
  18.  
  19. (defrule watch_with_family (companion family)
  20. =>
  21. (printout t crlf)
  22. (printout t "Let me select a movie suitable to watch with your family..." crlf crlf)
  23. (assert (genre
  24. (input "Enter your preferred genre (animation/fantasy/horror): ")
  25. ))
  26. )
  27.  
  28. (defrule watch_with_partner (companion partner)
  29. =>
  30. (printout t crlf)
  31. (printout t "Let me select a movie suitable to watch with your partner..." crlf crlf)
  32. (assert (genre
  33. (input "Enter your preferred genre (crime/comedy/drama): ")
  34. ))
  35. )
  36.  
  37. (defrule watch_alone (companion alone)
  38. =>
  39. (printout t crlf)
  40. (printout t "Let me select a movie that you can enjoy alone..." crlf crlf)
  41. (assert (genre
  42. (input "Enter your preferred genre (comedy/action/thriller): ")
  43. ))
  44. )
  45.  
  46. (defrule watch_animation_movie_with_family
  47. (companion family)
  48. (genre animation)
  49. =>
  50. (assert (suggested-movie "Finding Nemo"))
  51. )
  52.  
  53. (defrule watch_fantasy_movie_with_family
  54. (companion family)
  55. (genre fantasy)
  56. =>
  57. (assert (suggested-movie "Harry Potter"))
  58. )
  59.  
  60. (defrule watch_horror_movie_with_family
  61. (companion family)
  62. (genre horror)
  63. =>
  64. (assert (suggested-movie "The Conjuring"))
  65. )
  66.  
  67. (defrule watch_crime_movie_with_partner
  68. (companion partner)
  69. (genre crime)
  70. =>
  71. (assert (suggested-movie "Mr. & Mrs. Smith"))
  72. )
  73.  
  74. (defrule watch_comedy_movie_with_partner
  75. (companion partner)
  76. (genre comedy)
  77. =>
  78. (assert (suggested-movie "The Girl Next Door"))
  79. )
  80.  
  81. (defrule watch_drama_movie_with_partner
  82. (companion partner)
  83. (genre drama)
  84. =>
  85. (assert (suggested-movie "Casablanca"))
  86. )
  87.  
  88. (defrule watch_comedy_movie_alone
  89. (companion alone)
  90. (genre comedy)
  91. =>
  92. (assert (suggested-movie "Free Guy"))
  93. )
  94.  
  95. (defrule watch_action_movie_alone
  96. (companion alone)
  97. (genre action)
  98. =>
  99. (assert (suggested-movie "The Batman"))
  100. )
  101.  
  102. (defrule watch_thriller_movie_alone
  103. (companion alone)
  104. (genre thriller)
  105. =>
  106. (assert (suggested-movie "Don't Breathe 2"))
  107. )
  108.  
  109. (defrule suggest-movie (declare (salience -1))
  110. (suggested-movie ?movie)
  111. =>
  112. (printout t "-----------------------------------------------------------------------------" crlf)
  113. (printout t "The recommended movie which best suits your needs is: " ?movie crlf)
  114. (printout t "-----------------------------------------------------------------------------" crlf)
  115. )
  116.  
Add Comment
Please, Sign In to add comment