 
 (defn- ghost-incr [state]
   (assoc state :ghost
-         (ghost/filter-active-nodes (ghost/incr (:ghost state) (:poss-fn state))
+         (ghost/filter-active-nodes (ghost/incr (:ghost state) (mk-poss-fn state))
                                     #(let [[minb maxb] (quil-bounds state 2)]
                                        (in-bounds? minb maxb (:pos %1))))))
 


(defn update-state [state]
  (-> state
      (update-in [:frame] inc)
      (ghost-incr)
      (ghost-expire-roots)
      (maybe-exit)))

(defn- ellipse [state pos size] ; size is [w h]

      (doseq [line lines]
        (apply q/line (apply concat (map #(scale state %) line))))

      ;(q/stroke 0xFF000000)
      ;(q/fill 0xFFFFFFFF)
      ;(doseq [leef leaves]
      ;  (let [pos (:pos leef)]
      ;    (ellipse state pos [0.5 0.5])
      ;    ))

      ;(q/stroke 0xFF000000)
      ;(q/fill 0xFF000000)
      ;(doseq [active-node active]
      ;  (let [pos (:pos active-node)]
      ;    (ellipse state pos [0.5 0.5])
      ;    ))


      ))

    (when-not (zero? (:gif-seconds state))
      (let [anim-frames (* (:gif-seconds state) (:frame-rate state))]
        (gil/save-animation "quil.gif" anim-frames 0)
        (when (> (:frame state) anim-frames) (q/exit))))

    (q/text (clojure.string/join
              "\n"
              (list
                (format "frame:%d" (:frame state))
                (format "second:%f" (curr-second state))
                (format "spawn-chance:%d" (spawn-chance state))))
            30 30)
  )

(defn main []
