anchor.diff:  ;;; startup rule...
   
   (defun startup ()
  -  (assert (monkey ? location t5-7 on-top-of green-couch holding blank))
  -  (assert (thing ? name green-couch location t5-7 weight heavy
  -                 on-top-of floor))
  -  (assert (thing ? name red-couch location t2-2 
  -                 on-top-of floor weight heavy))
  -  (assert (thing ? name big-pillow location t2-2 
  -                 weight light on-top-of red-couch))
  -  (assert (thing (name red-chest) (location t2-2) 
  -                 (weight light) (on-top-of big-pillow)))
  -  (assert (chest (name red-chest) (contents ladder) (unlocked-by red-key)))
  -  (assert (thing (name blue-chest) (location t7-7) 
  -                 (weight light) (on-top-of ceiling)))
  -  (assert (thing (name grapes) (location t7-8) 
  -                 (weight light) (on-top-of ceiling)))
  -  (assert (chest (name blue-chest) (contents bananas) (unlocked-by blue-key)))
  -  (assert (thing (name blue-couch) (location t8-8) 
  -                 (on-top-of floor) (weight heavy)))
  -  (assert (thing (name green-chest) (location t8-8) 
  -                 (weight light) (on-top-of ceiling)))
  -  (assert (chest (name green-chest) (contents blue-key) (unlocked-by red-key)))
  -  (assert (thing (name red-key) 
  -                 (on-top-of floor) (weight light) (location t1-3)))
  -  (assert (goal-is-to (action eat) (argument-1 bananas) (argument-2 empty))))
  -
  -#+ignore
  -(defun run-mab (&optional (ntimes 1))
  -  (let ((start (get-internal-real-time)))
  -    (dotimes (i ntimes)
  -      (format t "Starting run.~%")
  -      (reset)
  -      (run))
  -    (format t "Elapsed time: ~F~%"
  -            (/ (- (get-internal-real-time) start)
  -               internal-time-units-per-second))))
  +  (make-instance 'monkey :location 't5-7 :on-top-of 'green-couch
  +                 :holding 'blank)
  +  (make-instance 'thing :name 'green-couch :location 't5-7 :weight 'heavy
  +                 :on-top-of 'floor)
  +  (make-instance 'thing :name 'red-couch :location 't2-2 
  +                 :on-top-of 'floor :weight 'heavy)
  +  (make-instance 'thing :name 'big-pillow :location 't2-2 
  +                 :weight 'light :on-top-of 'red-couch)
  +  (make-instance 'thing :name 'red-chest :location 't2-2 
  +                 :weight 'light :on-top-of 'big-pillow)
  +  (make-instance 'chest :name 'red-chest :contents 'ladder :unlocked-by 'red-key)
  +  (make-instance 'thing :name 'blue-chest :location 't7-7 
  +                 :weight 'light :on-top-of 'ceiling)
  +  (make-instance 'thing :name 'grapes :location 't7-8 
  +                 :weight 'light :on-top-of 'ceiling)
  +  (make-instance 'chest :name 'blue-chest :contents 'bananas :unlocked-by 'blue-key)
  +  (make-instance 'thing :name 'blue-couch :location 't8-8 
  +                 :on-top-of 'floor :weight 'heavy)
  +  (make-instance 'thing :name 'green-chest :location 't8-8 
  +                 :weight 'light :on-top-of 'ceiling)
  +  (make-instance 'chest :name 'green-chest :contents 'blue-key :unlocked-by 'red-key)
  +  (make-instance 'thing :name 'red-key 
  +                 :on-top-of 'floor :weight 'light :location 't1-3)
  +  (make-instance 'goal-is-to :action 'eat :argument-1 'bananas))
   
   (defun run-mab (&optional (ntimes 1))
     (flet ((repeat-mab ()
              (dotimes (i ntimes)
                (format t "Starting run.~%")
                (reset)
  -             (run))))
  +             (startup)
  +             (infer :contexts '(mab)))))
       (time (repeat-mab))))
  -
  -#+Allegro
  -(defun profile-mab (&optional (ntimes 10))
  -  (prof:with-profiling (:type :time)
  -    (run-mab ntimes)))
  -
  -#+LispWorks
  -(defun profile-mab (&optional (ntimes 10))
  -  (hcl:set-up-profiler :packages "LISA")
  -  (hcl:profile (run-mab ntimes)))
  
positive.code: ;;; Chest-unlocking rules...
  
  (defrule hold-chest-to-put-on-floor :forward :context mab
    (goal-is-to ?goal action unlock argument-1 ?chest)
    (thing ?thing name ?chest on-top-of ?top weight light)
    (test (not (eql ?top 'floor)))
    (not (monkey ?monkey holding ?chest))
    (not (goal-is-to ? action hold argument-1 ?chest))
    -->
    ((format t "hold-chest-to-put-on-floor fired~%"))
    (assert (goal-is-to ? action hold argument-1 ?chest)))
  
  (defrule put-chest-on-floor :forward :context mab
  
negative.code:   (erase ?goal))
  
  (defrule drop-object :forward :context mab
    (goal-is-to ?goal action hold argument-1 blank)
    (monkey ?monkey location ?place on-top-of ?on
            holding ?name)
    (test (not (eql ?name 'blank)))
    (thing ?thing name ?name)
    -->
    ((format t "Monkey drops the ~A.~%" ?name))
  