;;; Get the state out of the most recent move of path.
;;; Input:  A path
;;; Output:  The state of the path (i.e. the state of the first element of the path)
;;; Side-effects:  None
(defun get-current-state (path) (get-state (first path)))

;;; These functions here are helper functions for RBFS
;;; For RBFS, we're going to use a slightly different data structure.
;;; The repeat loop of the RBFS algorithm keeps track of the f-score of a given node (path)
;;; and alters it based on various components of the algorithm.  So,
;;; instead of just a path, we will keep a list with the path and the f-limit
;;; assigned to that node (i.e.  (path f-value)).

;;; Given an RBFS-path, return the score portion
;;; Input:  a list containing two items, the first is a path and the second is a score
;;; Output:  The score portion of the list
;;; Side-effects:  None
(defun get-score (p)
  (second p))

;;; Given an RBFS-path, return the  node (or path) portion
;;; Input:  a list containing two items, the first is a path and the second is a score
;;; Output:  The path portion of the list
;;; Side-effects:  None
(defun get-node (p)
  (first p))

;;; This function will help us merge out lists.  This function takes two
;;; RBFS-paths and compares the f-scores of the two.
;;; Input: two RBFS-paths (a list containing two items, the first is a path and 
;;;the second is a score)
;;; Output:  T if the score of path1 <= the score of path2, Nil otherwise
;;; Side-effects: None
(defun list-comp (path1 path2)
  (<= (get-score path1) (get-score path2)))

;;; Given a list of paths, return a new list containing RBFS-paths
;;; Input:  p, A list of paths and f, a score function (like out-of-place-f)
;;; Output:  A list of RBFS-paths (an RBFS-path consists of a two item list with the first item
;;; being a path and the second item the f-score of the path.
;;; Side-effects: None
(defun make-score-list (p f)
   (if (endp p) '()
     (cons (cons (car p) (list (funcall f (car p)))) (make-score-list (cdr p) f))))


