anchor.diff:                 (swap state i j)))))
           direction))
   
  -(defparameter *target* (vector 0  1  2
  -                               3  -1 4
  -                               5  6  7
  -                               8  -1 9
  -                               10 11 12))
  -
   (defparameter *width* 3)
  +
  +(defparameter *target* (vector 0 1 2
  +                               3 4 5
  +                               6 7 8))
  +
  +(defparameter *start* (vector 5 1 8
  +                              7 2 3
  +                              0 6 4))
   
   (defun goalp (node)
     (equalp node *target*))
   
  -(defun successor (heuristic old-state old-direction)
  -  (mapcar (lambda (state-direction)
  -            (let ((state (car state-direction))
  -                  (direction (cdr state-direction)))
  -              (vector direction state (funcall heuristic state))))
  -          (remove nil
  -                  (mapcar (lambda (direction)
  -                            (move-blank old-state direction))
  -                          (remove (case old-direction
  -                                    (UP 'DOWN)
  -                                    (DOWN 'UP)
  -                                    (RIGHT 'LEFT)
  -                                    (LEFT 'RIGHT))
  -                                  '(UP DOWN RIGHT LEFT)))
  -                  :key #'car)))
  +(defun action (old-state old-direction)
  +  ;; return a dotted list (state . direction)
  +  (remove nil
  +          (mapcar (lambda (direction)
  +                    (move-blank old-state direction))
  +                  (remove (case old-direction
  +                            (UP 'DOWN)
  +                            (DOWN 'UP)
  +                            (RIGHT 'LEFT)
  +                            (LEFT 'RIGHT))
  +                          '(UP DOWN RIGHT LEFT)))
  +          :key #'car))
   
   (defun n-puzzle (search heuristic initial-state)
  -  (tree-search search #'successor heuristic #'goalp initial-state))
  -
  +  (funcall search #'action heuristic #'goalp initial-state))
  +
  +(format t "A*-search~%")
  +(time (format t "~A~%" (n-puzzle #'IDA*-search
  +                                 #'manhattan
  +                                 *start*)))
  +
  +(format t "IDA*-search~%")
   (time (format t "~A~%" (n-puzzle #'A*-search
                                    #'manhattan
  -                                 (vector 3  1  2
  -                                         8  -1 4
  -                                         0  10 5
  -                                         11 -1 7
  -                                         12 9  6))))
  +                                 *start*)))
  
positive.code: 
  (defstruct fringe
    (key #'identity)
    (elements (make-heap))) ; Heap
  
  (defun fringe-remove (q)
    (heap-pop (fringe-elements q) (fringe-key q)))
  
negative.code:   (path-cost 0)
    (depth 0))
  
  (defun direction-sequence (node)
    (labels ((direction-sequence-iter (node directions)
               (if (null (node-parent node))
  