summary refs log tree commit diff
path: root/lib/cells.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cells.fnl')
-rw-r--r--lib/cells.fnl13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/cells.fnl b/lib/cells.fnl
index 442c7c7..dde8372 100644
--- a/lib/cells.fnl
+++ b/lib/cells.fnl
@@ -12,8 +12,8 @@
 (fn neighbors> [f threshold]
   (var x 0)
   ;; nnn this could be faster maybe
-  (each [k v (ipairs neighbors)]
-    (when (> (cell.aliveness (f v)) threshold)
+  (for [k 1 8]
+    (when (> (cell.aliveness (f (. neighbors k))) threshold)
       (set x (+ x 1))))
   x)
 
@@ -28,10 +28,11 @@
          nil))
    cell.update
    (fn [self get]
-     (if (or (= (neighbors> get 0) 3)
-             (= (neighbors> get 0) 2))
+     (let [n (neighbors> get 0)]
+       (if (or (= n 3)
+               (= n 2))
          self
-         nil))
+         nil)))
    cell.aliveness
    #1
    cell.color
@@ -58,8 +59,6 @@
    cell.color
    #(if (= $.stage 0)
         [0.7 0.4 0.3]
-        (= $.stage 5)
-        [0.5 0.4 0.3]
         (= $.stage 1)
         [0.2 0.2 0.3])
    })