|
@@ -10,6 +10,7 @@
|
|
;; define your app data so that it doesn't get over-written on reload
|
|
;; define your app data so that it doesn't get over-written on reload
|
|
(defonce app-state (atom {
|
|
(defonce app-state (atom {
|
|
:text "Hello world!"
|
|
:text "Hello world!"
|
|
|
|
+ :binary-rule (automata.rules.preset-rules :110)
|
|
:rule (automata.rules.string-to-rule (automata.rules.preset-rules :110))
|
|
:rule (automata.rules.string-to-rule (automata.rules.preset-rules :110))
|
|
:board [(automata.init.init-random 15)]
|
|
:board [(automata.init.init-random 15)]
|
|
:interv 500
|
|
:interv 500
|
|
@@ -20,6 +21,7 @@
|
|
:active-color "red"
|
|
:active-color "red"
|
|
:inactive-color "blue"
|
|
:inactive-color "blue"
|
|
}
|
|
}
|
|
|
|
+ :desired-columns 15
|
|
}))
|
|
}))
|
|
|
|
|
|
;(swap! app-state assoc :board [(automata.init.init-random 55)])
|
|
;(swap! app-state assoc :board [(automata.init.init-random 55)])
|
|
@@ -38,6 +40,7 @@
|
|
|
|
|
|
(defn Board []
|
|
(defn Board []
|
|
[:table
|
|
[:table
|
|
|
|
+ {:id "board"}
|
|
[:tbody
|
|
[:tbody
|
|
(map-indexed Row (@app-state :board))]])
|
|
(map-indexed Row (@app-state :board))]])
|
|
|
|
|
|
@@ -46,24 +49,33 @@
|
|
(swap! app-state update-in [:board] conj (automata.rules.proc (last (@app-state :board)) (@app-state :rule))))
|
|
(swap! app-state update-in [:board] conj (automata.rules.proc (last (@app-state :board)) (@app-state :rule))))
|
|
|
|
|
|
|
|
|
|
-;(go (dotimes [n 100]
|
|
|
|
-; (<! (timeout 1000))
|
|
|
|
-; (println (str "beat" n))
|
|
|
|
-; (step)))
|
|
|
|
(defn start-stepping []
|
|
(defn start-stepping []
|
|
(go
|
|
(go
|
|
(while (@app-state :go)
|
|
(while (@app-state :go)
|
|
(step)
|
|
(step)
|
|
(<! (timeout 100)))))
|
|
(<! (timeout 100)))))
|
|
|
|
|
|
-(defn App []
|
|
|
|
|
|
+(defn Controls []
|
|
[:div
|
|
[:div
|
|
- [:button {:on-click (fn [] (swap! app-state update-in [:go] not) (start-stepping))} (if (@app-state :go) "stop" "go")]
|
|
|
|
|
|
+ {:class "controls"}
|
|
|
|
+ [:button {:on-click (fn [] (swap! app-state update-in [:go] not) (start-stepping))} (if (@app-state :go) "stop" "GO")]
|
|
[:button {:on-click (fn [] (step))} "step"]
|
|
[:button {:on-click (fn [] (step))} "step"]
|
|
[:button {:on-click (fn [] (swap! app-state assoc :board [(automata.init.init-random 55)]))} "reset"]
|
|
[:button {:on-click (fn [] (swap! app-state assoc :board [(automata.init.init-random 55)]))} "reset"]
|
|
- [Board]
|
|
|
|
|
|
+ [:hr]
|
|
|
|
+ "columns"
|
|
|
|
+ [:input {:type "number" :min 1 :value (@app-state :desired-columns) :on-change (fn [e] (swap! app-state assoc :desired-columns e.target.value))}]
|
|
|
|
+ [:button {:on-click (fn [] (println "change number of columns to" (@app-state :desired-columns)))} "change"]
|
|
|
|
+ [:hr]
|
|
|
|
+ "rules"
|
|
|
|
+ ;(println (interleave (automata.rules.rule-order) (@app-state :binary-rule)))
|
|
|
|
+ (println "hi" (@app-state :binary-rule) automata.rules.rule-order)
|
|
])
|
|
])
|
|
|
|
|
|
|
|
+(defn App []
|
|
|
|
+ [:div
|
|
|
|
+ [Controls]
|
|
|
|
+ [Board]])
|
|
|
|
+
|
|
(reagent/render-component [App]
|
|
(reagent/render-component [App]
|
|
(. js/document (getElementById "app")))
|
|
(. js/document (getElementById "app")))
|
|
|
|
|