anchor.diff:      (cond
         ;; No next state
         ;; In that case, return a state stack with last state removed
  -      ;; After all, from this state we didn't get anywhere.
  -      ;; Then increase the branch index of this new last state.
  -      ;; This is done in order for the next try to take another route
  -      ;; and not to fall into the same pitfall.
  -      ((null next-state)
  -       (let ((backtrack (rest states-stack)))
  -         (when backtrack
  -           (incf (the fixnum (getf (first backtrack) :branch-idx))))
  -         backtrack))
  +      ;; as this last state did lead us to a dead end.
  +      ;; But before doint so, increase the branch index of a predecessor of the last state.
  +      ;; This is done in order to try another route next time we search
  +      ;; for a valid move.
  +      ((null next-state) (let ((backtrack (rest states-stack)))
  +                           (when backtrack
  +                             (incf (getf (first backtrack) :branch-idx)))
  +                           backtrack))
         ;; Found a next state
  -      ;; IN this case set the branch index to the 
  +      ;; In that case set the branch index to the
  +      ;; index of a branch taken and return new states stack
         (t (setf (getf (first states-stack) :branch-idx) idx)
            (cons next-state states-stack)))))
   
  
positive.code: 
  ;;; Check if a given state have already been visited
  (defun visited-state-p (state states-stack)
    (declare (cons states-stack))
    (find-if #'(lambda(s) (states-equal-p s state)) states-stack))
  
  ;;; Returns next possible state
  ;;; given current state and one of the
  ;;; possible moves.
  (defun get-next-state (m c state-stack move-idx)
    (declare (fixnum move-idx))
    (let ((current-state (first state-stack)))
      (let ((move (nth move-idx *valid-moves-r-to-l*)))
        (when (getf current-state :has-boat)
          (setf move (nth move-idx *valid-moves-l-to-r*)))
        (if move
            (let* ((missionaries (+ (the fixnum (getf current-state :missionaries)) (the fixnum (getf move :missionaries))))
                   (cannibals (+ (the fixnum (getf current-state :cannibals)) (the fixnum (getf move :cannibals))))
                   (has-boat (not (getf current-state :has-boat)))
                   (next-state (new-state :missionaries missionaries :cannibals cannibals :has-boat has-boat)))
              (and (valid-state-p m c next-state) (not (visited-state-p next-state state-stack)) next-state))))))
  
  ;;; Finds a valid next state for given current state
  
negative.code:     (let ((current-state (first states-stack)))
        (when current-state
          (loop
             for move-idx from (getf current-state :branch-idx) to (length (getf *valid-moves* :with-boat))
             for next-state = (get-next-state m c states-stack move-idx) then (get-next-state m c states-stack move-idx)
             when next-state return (values next-state move-idx))))))
  
  