 (defn hfs-can-reach? [hfs s]
   (or (seq (:remaining-actions hfs)) (= s (:state hfs))))
 
+(defn hfs-cycle-level [hfs]
+  (when-let [a (first (:remaining-actions hfs))] (hierarchy/cycle-level a (:state hfs))))
+
 (defn hfs-optimistic-map [hfs]
   (let [{:keys [state remaining-actions]} hfs]
     (assert (util/singleton? remaining-actions))



(comment
  (do (use '[exp env hierarchy taxi ucs] 'edu.berkeley.ai.util) (require '[exp sahucs-simple sahucs-inverted saha-simple] '[exp.old ahois]))
  (let [e (make-random-taxi-env 5 5 5 3) _ (println e) h (simple-taxi-hierarchy e)]  
    (time (println "ucs" (run-counted #(second (uniform-cost-search e)))))
    (doseq [alg `[sahucs-flat sahucs-fast-flat exp.sahucs-simple/sahucs-simple sahucs-simple exp.sahucs-inverted/sahucs-inverted sahucs-inverted exp.saha-simple/saha-simple saha-simple ]]
      (time (println alg (run-counted #(debug 0 (second ((resolve alg) h)))))))))
(defn sahucs-simple [henv]
  (hierarchical-search henv nil make-recursive-search))

(defn sahucs-dijkstra [henv]
  (hierarchical-search henv nil make-acyclic-recursive-search))

(defn sahucs-inverted [henv]
  (hierarchical-search henv nil make-inverted-search))

