 (println "test mk-system-fn"
          ((mk-system-fn (fn [s fns ents] s) :b) {:entities {:a [:b]}}))
 
+(defn mk-system
+  "Add the system function to the state. Wraps the system function using
+   mk-system-fn. Returns an update hashmap."
+  [state uid f & [component-id]]
+  (let [system-fn (if component-id
+                    (mk-system-fn f component-id)
+                    (mk-system-fn f))]
+    (assoc-in state [:systems uid] system-fn)))
+
 (defn integration-test
   "Test the entire CES implementation with a system that changes component state"
   []
-  (let [sys-fn (fn [state fns entity-ids]
-                 (apply deep-merge (for [f fns, e entity-ids] (f state e))))
-        test-system (mk-system-fn sys-fn :testable)
+  (let [test-system-fn (fn [state fns entity-ids]
+                         (apply deep-merge (for [f fns, e entity-ids]
+                                             (f state e))))
         test-fn (fn [component-state entity-id]
                   (println "testing" entity-id
                            component-state "->"


(println "test iter-fns" (iter-fns {} [#(assoc % :yo :dawg)]))

(defn game-loop
  [state scene-id frame-count]
  (if (< frame-count 10)
    (recur (iter-fns state (-> state :scenes scene-id))
           scene-id
           (inc frame-count))
    state))

          {} :yo))

(defn mk-component
  "Returns an updated state hashmap with the given component.
   Wraps each function in fns with mk-component-fn.

   The return value of any component function should be the updated
