Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;; monkeys1. El original. Se mete en bucles infinitos ..
- (defrule start (initial-fact) => (assert (door start room1))
- (assert (door room1 room2))
- (assert (door room2 room3))
- (assert (door room3 room4))
- (assert (door room2 room1))
- (assert (location crate room4 middle))
- (assert (location bananas room4 bottom top))
- (assert (location monkey start))
- (assert (goal monkey full))
- (assert (goal monkey to-start-again))
- )
- (defrule move
- ?lm <- (location monkey ?loc1)
- (door ?loc1 ?loc2)
- (not (was-location monkey ?loc2))
- =>
- (assert (location monkey ?loc2))
- (assert (was-location monkey ?loc1))
- (retract ?lm)
- (printout t "move from " ?loc1 " to " ?loc2 crlf)
- )
- (defrule moveCrate (location monkey room4)
- ?lc <- (location crate room4 middle)
- (location bananas room4 bottom top)
- =>
- (assert (location crate room4 bottom))
- (retract ?lc)
- (printout t "move crate" crlf)
- )
- (defrule climbCrate ?lm <- (location monkey room4)
- (location crate room4 bottom)
- (location bananas room4 bottom top)
- =>
- (assert (location monkey room4 onCrate))
- (retract ?lm)
- (printout t "climb" crlf)
- )
- (defrule getBananas (location monkey room4 onCrate)
- ?lb <- (location bananas room4 bottom top)
- =>
- (assert (location bananas withMonkey))
- (retract ?lb)
- (printout t "get" crlf)
- )
- (defrule eatBananas ?lb <- (location bananas withMonkey)
- =>
- (assert (monkey full))
- (retract ?lb)
- (printout t "eat" crlf)
- )
- (defrule goDown
- ?lm <- (location monkey room4 onCrate)
- (monkey full)
- =>
- (assert (location monkey room4))
- (retract ?lm)
- (printout t "go down crate" crlf)
- )
- (defrule puertas (declare (salience 5))
- ?lm <- (door ?loc1 ?loc2)
- (not ( door ?loc2 ?loc1))
- =>
- (assert (door ?loc2 ?loc1))
- (printout t "create door" crlf)
- )
- (defrule eliminaCallejones (declare (salience -5))
- ?lm <- (was-location monkey ?loc1)
- =>
- (retract ?lm)
- )
- (defrule moveGoal (logical (goal monkey full))
- =>
- (assert goal monkey to-start-again)
- (retract was-location monkey ?loc1)
- )
- ;;;retract fully assert start again en los platanos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement