     (actions state)))
 
 (defn stratified-search [sas-problem type]
-  (assert (#{:simple :dynamic} type))
+  (assert (#{:simple :dynamic :fluid} type))
   (let [q       (queues/make-tree-search-pq)
         closed  (HashSet.)
         actions (env/actions-fn sas-problem)

;; 6-2: 1947242
;; 5-0: 2272572





            (.addAll open (av-map x))))))
    (set (seq ret))))

(defn dynamic-inf-stratified-applicable-actions [last-a state tsi av-map ap-map actions]
  (if last-a
    (let [a-var   (effect-var last-a)
          a-level (util/safe-get tsi a-var)
          p-set   (dynamic-var-set state av-map ap-map a-var)]
      (filter
       (fn [b]
         (let [b-var (effect-var b)
               b-level (util/safe-get tsi b-var)]
           (or (and (<= b-level a-level) (contains? p-set b-var))
               (contains? (:precond-map b) a-var))))       
       (actions state)))
    (actions state)))

(defn fluid-predecessors [state ap-map v]
  (apply clojure.set/intersection
         (for [a (util/safe-get ap-map [v (state/get-var state v)])
               :when (contains? (:effect-map a) v)]
           (set (for [[pvar pval] (:precond-map a)
                      :when (and (not (= pvar v)) (not (= pval (state/get-var state pvar))))]
                  pvar)))))


(defn fluid-vars [state ap-map goal]
  (let [open   (ArrayList.)
        ret    (HashSet.)
        closed (HashSet.)]
    (doseq [[var val] goal]
      (when-not (= val (state/get-var state var))
        (.add open var)))
    (while (not (.isEmpty open))
      (let [v (.remove open (dec (count open)))]
        (when-not (.contains closed v)
          (.add closed v)
          (.addAll open (fluid-predecessors state ap-map v)))))
    (set (seq closed))))

(defn dynamic-fluid-inf-stratified-applicable-actions [last-a state tsi av-map ap-map root-set goal cg-map actions]
  ;; Root set ignored for now -- doing it dynamically.
  (if last-a
    (let [a-var   (effect-var last-a)
          a-level (util/safe-get tsi a-var)
          p-set   (dynamic-var-set state av-map ap-map a-var)
          fluid-set (clojure.set/intersection p-set (fluid-vars state ap-map goal))
          fluid-root-set (set (for [v fluid-set
                                    :let [av (av-map v)]
                                    :when (every? (fn [a] (every? #(or (av %) (not (p-set %))) (cg-map a))) (disj av v))]
                                v)) 
          p-set   (if (seq fluid-root-set)
                    (av-map (apply min-key tsi fluid-root-set))
                    p-set)]
      (filter
       (fn [b]
         (let [b-var (effect-var b)
               b-level (util/safe-get tsi b-var)]
           (or (and (<= b-level a-level) (contains? p-set b-var))
               (contains? (:precond-map b) a-var))))       
       (actions state)))
    (actions state)))
