From 78530480d35be5dbb57f1a264147bec48d6cf800 Mon Sep 17 00:00:00 2001 From: equa Date: Sun, 18 Apr 2021 14:45:55 -0500 Subject: visual changes (zooming) and optimization also profiling --- lib/cells.fnl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/cells.fnl') 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]) }) -- cgit 1.3.0-6-gf8a5