|
@@ -1,15 +1,19 @@
|
|
|
(ns automata.core
|
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
|
|
[automata.rules]
|
|
|
- [automata.init]))
|
|
|
+ [automata.init]
|
|
|
+ [cljs.core.async :as async :refer [chan <! >! timeout put!]])
|
|
|
+ (:require-macros [cljs.core.async.macros :refer [go alt!]]))
|
|
|
|
|
|
(enable-console-print!)
|
|
|
|
|
|
;; define your app data so that it doesn't get over-written on reload
|
|
|
(defonce app-state (atom {
|
|
|
:text "Hello world!"
|
|
|
- :rule "01101110"
|
|
|
+ :rule (automata.rules.string-to-rule (automata.rules.preset-rules :110))
|
|
|
:board [(automata.init.init-random 15)]
|
|
|
+ :interv 500
|
|
|
+ :go false
|
|
|
:style {
|
|
|
:cell-size 40
|
|
|
:border-thickness 0
|
|
@@ -18,7 +22,7 @@
|
|
|
}
|
|
|
}))
|
|
|
|
|
|
-;(swap! app-state assoc :board [(automata.init.init-random 15)])
|
|
|
+;(swap! app-state assoc :board [(automata.init.init-random 55)])
|
|
|
|
|
|
(defn Cell [row ind value]
|
|
|
[:td
|
|
@@ -36,10 +40,15 @@
|
|
|
[:table
|
|
|
(map-indexed Row (@app-state :board))])
|
|
|
|
|
|
-(println "well?" (automata.rules.proc (last (@app-state :board)) (automata.rules.string-to-rule (automata.rules.preset-rules :110))))
|
|
|
-;; this is incorrect
|
|
|
-;(defn step []
|
|
|
-; (swap! app-state update-in :board conj (automata.rules.proc (last (@app-state :board)) (automata.rules.string-to-rule (automata.rules.preset-rules :110)))))
|
|
|
+
|
|
|
+(defn step []
|
|
|
+ (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 App []
|
|
|
[Board])
|