 ;; 6-2: 3286212
 ;; 5-0: 4053436
 
+;; Logistics results (# states) to match table. -- dynamic
+;; 5-2: 16086
+;; 6-1: 194870
+;; 4-2: 277791
+;; 5-1: 454016
+;; 4-1: 750217
+;; 4-0: 986574
+;; 6-3: 1908549
+;; 6-0: 1864844
+;; 6-2: 1947242
+;; 5-0: 2272572
+
+
+
+
 ;; Wrong ? 
 ;; Logistics results (# states) to match table. -- structural
 ;; 5-2: 8585


(defn effect-var [a] (util/safe-singleton (keys (:effect-map a))))

;; 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)
          e-p-set (set (for [b (get ap-map (util/safe-singleton (seq (:effect-map last-a))))
                             [pvar pval] (:precond-map b)
                             :when (not (= (state/get-var state pvar) pval))]
                         pvar))
          p-set   (apply clojure.set/union (map av-map e-p-set))]
      (util/prln (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)) last-a))
    (actions state)))

(comment (some #(= ((:precond-map last-a) %) ((:precond-map b) %))

;; 6-0: 3435578
;; 6-2: 3286212
;; 5-0: 3085333
