Comparing parsed and sensed objects
(defun objects-agree (parsed-object sensed-object sensed-object-position)
(or (null (object-color parsed-object))
(eq (object-color parsed-object) (wobject-color sensed-object)))
(or (null (object-shape parsed-object))
(eq (object-shape parsed-object) 'BLOCK)
(eq (object-shape parsed-object) (wobject-shape sensed-object)))
(or (null sensed-object-position)
(member sensed-object-position (possible-object-positions parsed-object)))))
;;; The argument is an object description, and can contain a relative
;;; LOCATION clause. Return all positions that are consistent with
;;; both the relative clause *and* with the object's shape and color.
(defun possible-object-positions (object)
(let* ((dest-positions (possible-destination-positions (object-place object)))
(obj-positions (find-objects (object-color object) (object-shape object))))
(intersection obj-positions dest-positions)))
;;;******************************************************
;;; Return a list of positions this LOCATION
;;; structure could possibly refer to. If it is empty,
;;; return the list of all positions.
(defun possible-destination-positions (location)
((location-abs-position location)
(list (location-abs-position location)))
((location-rel-direction location)
(apply-direction (location-rel-direction location)
(possible-object-positions (location-rel-object location))))
(T (all-possible-positions))))