         cg-map        (graphs/edge-list->outgoing-map causal-graph)
         av-map        (into {} (for [v (keys (:vars sas-problem))]
                                  [v (graphs/ancestor-set causal-graph [v])]))
+        root-set      (set (for [[v av] av-map
+                                 :when (every? (fn [a] (every? av (cg-map a))) (disj av v))]
+                             v))
         cav-map       (into {} (for [v (keys (:vars sas-problem))]
                                  [v (apply clojure.set/union (map av-map (cg-map v)))]))
         ap-map        (HashMap.)
 ;        pre-var-map   (util/map-vals #(set (map first %)) (group-by second causal-graph))
         tsi           (graphs/topological-sort-indices (remove #(apply = %) causal-graph))
+        goal-map (:precond-map (util/safe-singleton (filter #(= (:name %) sas/goal-action-name) (:actions sas-problem))))
         goal    (env/goal-fn sas-problem)
         init    (env/initial-state sas-problem)
         strat-actions (case type
                         :simple     (fn [last-a state] (inf-stratified-applicable-actions last-a state tsi actions))
-                        :structural (fn [last-a state] (improved-inf-stratified-applicable-actions last-a state tsi cav-map actions))                       :dynamic    (fn [last-a state] (dynamic-inf-stratified-applicable-actions last-a state tsi av-map ap-map actions)))]
-    (when (= type :dynamic) #_ (println av-map)
+                        :structural (fn [last-a state] (improved-inf-stratified-applicable-actions last-a state tsi cav-map actions))                       :dynamic    (fn [last-a state] (dynamic-inf-stratified-applicable-actions last-a state tsi av-map ap-map actions))
+                        :fluid    (fn [last-a state] (dynamic-fluid-inf-stratified-applicable-actions last-a state tsi av-map ap-map root-set goal-map cg-map actions))
+                        )]
+    (println root-set)
+    (when (#{:dynamic :fluid} type) #_ (println av-map)
       (doseq [a (:actions sas-problem), pp (:precond-map a)]
         (.put ap-map pp (cons a (.get ap-map pp)))))    
     (queues/pq-add! q [nil init] 0)

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

;; TODO: none of these work!
(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)]
   #_   (println last-a p-set state)
      (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? (util/keyset (:precond-map b)) (keys (:precond-map last-a)))
               (contains? (:precond-map b) a-var))))       
       (actions state)))
    (actions state)))

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

;; Logistics results (# states) to match table. -- fluid
;; 5 5-2: 10230
;; 7 6-1: 96430
;; 2 4-2: 182321
;; 4 5-1: 229929
;; 1 4-1: 324127
;; 0 4-0: 473231
;; 9 6-3: 1087515
;; 6 6-0: 899623
;; 8 6-2: 903447
;; 3 5-0: 1155503



