|
@@ -1,6 +1,7 @@
|
|
(ns automata.core
|
|
(ns automata.core
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
|
(:require [reagent.core :as reagent :refer [atom]]
|
|
- [automata.rules]))
|
|
|
|
|
|
+ [automata.rules]
|
|
|
|
+ [automata.init]))
|
|
|
|
|
|
(enable-console-print!)
|
|
(enable-console-print!)
|
|
|
|
|
|
@@ -8,10 +9,40 @@
|
|
(defonce app-state (atom {
|
|
(defonce app-state (atom {
|
|
:text "Hello world!"
|
|
:text "Hello world!"
|
|
:rule "01101110"
|
|
:rule "01101110"
|
|
|
|
+ :board [(automata.init.init-random 15)]
|
|
|
|
+ :style {
|
|
|
|
+ :cell-size 40
|
|
|
|
+ :border-thickness 0
|
|
|
|
+ :active-color "red"
|
|
|
|
+ :inactive-color "blue"
|
|
|
|
+ }
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
+;(swap! app-state assoc :board [(automata.init.init-random 15)])
|
|
|
|
+
|
|
|
|
+(defn Cell [row ind value]
|
|
|
|
+ [:td
|
|
|
|
+ {
|
|
|
|
+ :style {:background-color (if value "red" "blue")}
|
|
|
|
+ :key (str "r" row "c" ind)
|
|
|
|
+ }])
|
|
|
|
+
|
|
|
|
+(defn Row [ind row]
|
|
|
|
+ [:tr
|
|
|
|
+ {:key (str "row" ind)}
|
|
|
|
+ (map-indexed (partial Cell ind) row)])
|
|
|
|
+
|
|
|
|
+(defn Board []
|
|
|
|
+ [: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 App []
|
|
(defn App []
|
|
- [:div "hi"])
|
|
|
|
|
|
+ [Board])
|
|
|
|
|
|
(reagent/render-component [App]
|
|
(reagent/render-component [App]
|
|
(. js/document (getElementById "app")))
|
|
(. js/document (getElementById "app")))
|