 (defn make-asplan-env [sas-problem] 
   (def *add-count* (util/sref 0))
   (let [causal-graph  (remove #(apply = %) (sas-analysis/standard-causal-graph sas-problem))
+        vars          (graphs/ancestor-set causal-graph [sas/goal-var-name])
+        causal-graph  (filter (fn [[v1 v2]] (and (vars v1) (vars v2))) causal-graph)
+        av-map        (into {} (for [v vars] [v (graphs/ancestor-set causal-graph [v])]))
         child-var-map (util/map-vals #(map second %) (util/group-by first causal-graph))
-        vars          (keys (:vars sas-problem))
+;        vars          (keys (:vars sas-problem))
         dtgs          (sas-analysis/domain-transition-graphs sas-problem)
         simple-dtgs   (util/map-vals (fn [dtg] (for [[pval emap] dtg, [eval _] emap] [pval eval])) dtgs)
         acyclic-succ-fn (partial possibly-acyclic-successors (HashMap.) simple-dtgs)]


(deftype ASPlanEnv [init actions-fn g-map 
                    ; Following stuff is used by hierarchy.
                    causal-graph dtgs ancestor-var-map child-var-map acyclic-succ-fn]
  env/Env 
    (initial-state [] init)
    (actions-fn    [] actions-fn)
