    (let [[c1 c2 c3] (map #(:color %1) (keep #(get cells %1) (neighbors k)))]
      {:age 0 :color {:r (:r c1) :g (:g c2) :b (:b c3)}})))
 
+(defn create-cells [seed]
+  (into {} (for [k seed] [k (create-cell)])))
+
 (defn step [cells]
   (into {} (for [[k n] (->> (keys cells) (mapcat neighbors) (frequencies))
                  :let [cell (or (get cells k) (create-cell k cells))]
                  :when (or (= n 3) (and (= n 2) (contains? cells k)))]
              [k (update-in cell [:age] inc)])))
 
-
-;; -----------------------------------------------------------------------------
-;; Update / Render Cycle
+(defn setup-gol! []
+  (swap! state assoc-in [:gui :cells] (create-cells acorn)))
+
+(defn teardown-gol! []
+  (swap! state assoc-in [:gui :cells] nil))
+
+
+;; -----------------------------------------------------------------------------
+;; Update / Render / Cycle
 
 (defn update! []
-  (swap! state update-in [:gui :generation] inc))
+  (swap! state update-in [:gui :generation] inc)
+  (swap! state update-in [:gui :cells] step))
 
 (defn render! [timestamp state]
   (let [app-name (get-in state [:app :name])
         env-time (get-in state [:env :time])
-        fps (get-in state [:env :frames-per-second])
+        f-count (str "F: " (get-in state [:env :frame-count]))
+        fps (str "FPS: " (get-in state [:env :frames-per-second]))
         mouse-move (get-in state [:env :mouse-move])
         mouse-x (:client-x mouse-move)
         mouse-y (:client-y mouse-move)
-        mouse-pos (str "[" mouse-x ":" mouse-y "]")
-        gen (get-in state [:gui :generation])
-        display [gen fps env-time timestamp mouse-pos]]
+        mouse-pos (str "M: [" mouse-x ":" mouse-y "]")
+        generation (str "G: " (get-in state [:gui :generation]))
+        population (str "P: " (count (get-in state [:gui :cells])))
+        display [f-count fps generation population]]
     (set! (.-innerText (app-div)) (string/join ", " display))))
 
-(defn on-env-animation-frame [timestamp]
+(defn cycle! [timestamp]
   (update!)
   (render! timestamp @state)
   (get-in @state [:app :rendering?]))


;; -----------------------------------------------------------------------------
;; Event Handlers

(defn on-env-frames-per-second [fps]
  (swap! state assoc-in [:env :frames-per-second] fps)

;; Event Subscriptions

(defn setup-event-subscriptions! []
  (swap! state assoc-in [:app :count-frames?] true)
  (poly/listen-animation-frame! on-env-animation-frame)
  (swap! state assoc-in [:app :measure-fps?] true)
  (poly/listen-fps! on-env-frames-per-second)
  (poly/take-back! (get-event-channel :env-keyboard-key) on-env-keyboard-key)
  (poly/take-back! (get-event-channel :env-mouse-move) on-env-mouse-move))

(defn teardown-event-subscriptions! []
  (swap! state assoc-in [:app :count-frames?] false)
  (swap! state assoc-in [:env :frame-count] 0))
  (swap! state assoc-in [:app :measure-fps?] false)
  (swap! state assoc-in [:env :frames-per-second] 0)


;; -----------------------------------------------------------------------------
