   ;    (if (> chance-raw 0.97) 3 50)
   ;  ))
 
-(defn- spawn-all? [state]
-  (let [period-seconds 3
-        period-frames (* (:frame-rate state) period-seconds)]
-  (zero? (rem (:frame state) period-frames))))
-
 (defn- dist-from [pos1 pos2]
   (reduce + (map #(* % %) (map - pos1 pos2))))
 
+(def mk-poss-fns {
+                  :random (fn [state]
+                            (fn [pos adj-poss]
+                              (take 2 (random-sample 0.6 adj-poss))))
+
+                  :centered (fn [state]
+                              (let [spawn-all? (= 1 (:dial state))]
+                                (fn [pos adj-poss]
+                                  (let [to-take (if spawn-all? (count adj-poss) 1)]
+                                    (take to-take (sort-by #(dist-from % [0 0]) adj-poss))
+                                    ))))
+               })
+
 (defn- mk-poss-fn [state]
-  (let [spawn-all? (spawn-all? state)]
-    (fn [pos adj-poss]
-      (let [adj-poss (filter #(in-bounds? state %) adj-poss)
-            to-take (if spawn-all? (count adj-poss) 1)]
-        (take to-take (sort-by #(dist-from % [0 0]) adj-poss))
-        ))))
-
-;(defn- mk-poss-fn [state]
-;  (let [chance (spawn-chance state)]
-;    (fn [pos adj-poss]
-;      (if (zero? (rand-int chance))
-;        adj-poss
-;        (take 1 (shuffle adj-poss))))
-;    ))
-
-;(defn- mk-poss-fn [state]
-;  (fn [pos adj-poss]
-;    (take 2 (random-sample 0.6 adj-poss))))
-
-(defn setup []
-  (let [state (new-state)]
-    (q/frame-rate (:frame-rate state))
-    state))
-
-(defn- scale [state xy]
-  (map-indexed #(* %2 (float (/ (window-half-size %1)
-                                ((grid-size state) %1)))) xy))
-
-(defn- quil-bounds [state buffer]
-  (let [[w h] (apply vector (map #(- % buffer) (grid-size state)))]
-    [[(- w) (- h)] [w h]]))
-
-(defn- in-bounds? [state pos]
-  (let [[min-bound max-bound] (quil-bounds state 1)
-        pos-k (keep-indexed #(let [mini (min-bound %1)
-                                   maxi (max-bound %1)]
-                               (when (and (>= %2 mini) (<= %2 maxi)) %2)) pos)]
-    (= (count pos) (count pos-k))))
+  (let [chosen-poss-fn :centered
+        inner-fn ((chosen-poss-fn mk-poss-fns) state)]
+    (fn [pos adj-poss] (inner-fn pos (filter #(in-bounds? state %) adj-poss)))))
+
+;; ghost
 
 (defn- ghost-incr [state poss-fn]
   (update-in state [:ghost] ghost/incr poss-fn))

    ;            (gstring/format "spawn-chance:%d" (spawn-chance state))))
    ;        30 30)
  )

(q/defsketch viz
  :title ""

(defn- new-state []
  {:frame-rate 15
   :exit-wait-frames 40
   :tail-length 7
   :frame 0
   :dial 0
   :gif-seconds 0
   :grid-width 35 ; from the center
   :ghost (-> (ghost/new-ghost grid/isometric)
