;; A state has the form -> ((country color) (country color) ... )
;; The queue has the form -> ((value state) (value state) ... )
;; "search" sets up a loop where queue starts out as nil and on each
;; iteration gets set to the cdr of queue; expl starts out as the start
;; state.  If expl is a goal state it is returned, otherwise the
;; successors of expl are estimated, sorted, and merged into the queue.
;; expl is then set to the first state on the queue.  If the queue
;; becomes empty that means there is no solution and nil is returned.

(defun search (start goalp successors estimator)
  (do ((queue nil (cdr queue))
       (expl start))
      ((goalp expl) (return expl))
      (setq queue (state-merge (state-sort (successors expl) estimator)
			       queue))
      (setq expl (cadar queue))
      (cond ((null queue) (return nil)))))


