Advertisement
claukiller

carlos

Dec 1st, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. ;;; monkeys1. El original. Se mete en bucles infinitos ..
  2.  
  3.  
  4. (defrule start (initial-fact) => (assert (door start room1))
  5. (assert (door room1 room2))
  6. (assert (door room2 room3))
  7. (assert (door room3 room4))
  8. (assert (door room2 room1))
  9. (assert (location crate room4 middle))
  10. (assert (location bananas room4 bottom top))
  11. (assert (location monkey start))
  12. (assert (goal monkey full))
  13. (assert (goal monkey to-start-again))
  14.  
  15. )
  16.  
  17. (defrule move
  18. ?lm <- (location monkey ?loc1)
  19. (door ?loc1 ?loc2)
  20. (not (was-location monkey ?loc2))
  21. =>
  22. (assert (location monkey ?loc2))
  23. (assert (was-location monkey ?loc1))
  24. (retract ?lm)
  25. (printout t "move from " ?loc1 " to " ?loc2 crlf)
  26. )
  27.  
  28.  
  29. (defrule moveCrate (location monkey room4)
  30. ?lc <- (location crate room4 middle)
  31. (location bananas room4 bottom top)
  32. =>
  33. (assert (location crate room4 bottom))
  34. (retract ?lc)
  35. (printout t "move crate" crlf)
  36. )
  37.  
  38.  
  39. (defrule climbCrate ?lm <- (location monkey room4)
  40. (location crate room4 bottom)
  41. (location bananas room4 bottom top)
  42. =>
  43. (assert (location monkey room4 onCrate))
  44. (retract ?lm)
  45. (printout t "climb" crlf)
  46. )
  47.  
  48. (defrule getBananas (location monkey room4 onCrate)
  49. ?lb <- (location bananas room4 bottom top)
  50. =>
  51. (assert (location bananas withMonkey))
  52. (retract ?lb)
  53. (printout t "get" crlf)
  54. )
  55.  
  56. (defrule eatBananas ?lb <- (location bananas withMonkey)
  57. =>
  58. (assert (monkey full))
  59. (retract ?lb)
  60. (printout t "eat" crlf)
  61. )
  62.  
  63. (defrule goDown
  64. ?lm <- (location monkey room4 onCrate)
  65. (monkey full)
  66. =>
  67. (assert (location monkey room4))
  68. (retract ?lm)
  69. (printout t "go down crate" crlf)
  70. )
  71.  
  72. (defrule puertas (declare (salience 5))
  73. ?lm <- (door ?loc1 ?loc2)
  74. (not ( door ?loc2 ?loc1))
  75. =>
  76. (assert (door ?loc2 ?loc1))
  77. (printout t "create door" crlf)
  78. )
  79.  
  80. (defrule eliminaCallejones (declare (salience -5))
  81. ?lm <- (was-location monkey ?loc1)
  82. =>
  83. (retract ?lm)
  84. )
  85.  
  86. (defrule moveGoal (logical (goal monkey full))
  87. =>
  88. (assert goal monkey to-start-again)
  89. (retract was-location monkey ?loc1)
  90. )
  91.  
  92. ;;;retract fully assert start again en los platanos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement