|
@@ -27,7 +27,7 @@
|
|
(defn Cell [row ind value]
|
|
(defn Cell [row ind value]
|
|
[:td
|
|
[:td
|
|
{
|
|
{
|
|
- :style {:background-color (if value "red" "blue")}
|
|
|
|
|
|
+ :style {:background-color (if value "blue" "lightblue")}
|
|
:key (str "r" row "c" ind)
|
|
:key (str "r" row "c" ind)
|
|
}])
|
|
}])
|
|
|
|
|
|
@@ -38,7 +38,8 @@
|
|
|
|
|
|
(defn Board []
|
|
(defn Board []
|
|
[:table
|
|
[:table
|
|
- (map-indexed Row (@app-state :board))])
|
|
|
|
|
|
+ [:tbody
|
|
|
|
+ (map-indexed Row (@app-state :board))]])
|
|
|
|
|
|
|
|
|
|
(defn step []
|
|
(defn step []
|
|
@@ -49,9 +50,19 @@
|
|
; (<! (timeout 1000))
|
|
; (<! (timeout 1000))
|
|
; (println (str "beat" n))
|
|
; (println (str "beat" n))
|
|
; (step)))
|
|
; (step)))
|
|
|
|
+(defn start-stepping []
|
|
|
|
+ (go
|
|
|
|
+ (while (@app-state :go)
|
|
|
|
+ (step)
|
|
|
|
+ (<! (timeout 100)))))
|
|
|
|
|
|
(defn App []
|
|
(defn App []
|
|
- [Board])
|
|
|
|
|
|
+ [:div
|
|
|
|
+ [: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 [] (swap! app-state assoc :board [(automata.init.init-random 55)]))} "reset"]
|
|
|
|
+ [Board]
|
|
|
|
+ ])
|
|
|
|
|
|
(reagent/render-component [App]
|
|
(reagent/render-component [App]
|
|
(. js/document (getElementById "app")))
|
|
(. js/document (getElementById "app")))
|