diff options
author | equa <equaa@protonmail.com> | 2021-04-18 14:45:55 -0500 |
---|---|---|
committer | equa <equaa@protonmail.com> | 2021-04-18 14:48:02 -0500 |
commit | 78530480d35be5dbb57f1a264147bec48d6cf800 (patch) | |
tree | 197350b11e46593db326b563e0917e9536329aa1 /lib/cells.fnl | |
parent | 0c8a8cf8d861bc4ef3162e45e8b58d2f0173d2f7 (diff) |
visual changes (zooming) and optimization
also profiling
Diffstat (limited to 'lib/cells.fnl')
-rw-r--r-- | lib/cells.fnl | 13 |
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]) }) |