summary refs log tree commit diff
path: root/lib/cells.fnl
diff options
context:
space:
mode:
authorequa <equaa@protonmail.com>2021-04-18 20:22:20 -0500
committerequa <equaa@protonmail.com>2021-04-18 20:42:59 -0500
commitca870dab91daee38b8d55ac6d2f2b4fd6959c6ac (patch)
tree1b0445da67552162eac4e72e39330a777af7f7b6 /lib/cells.fnl
parent78530480d35be5dbb57f1a264147bec48d6cf800 (diff)
entities et al
Diffstat (limited to 'lib/cells.fnl')
-rw-r--r--lib/cells.fnl25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/cells.fnl b/lib/cells.fnl
index dde8372..3a43010 100644
--- a/lib/cells.fnl
+++ b/lib/cells.fnl
@@ -63,4 +63,27 @@
         [0.2 0.2 0.3])
    })
 
-{: life : brain}
+(local boom
+  {cell.init
+   (fn [self]
+     (setmetatable {:life 1} self))
+   cell.birth
+   (fn [self get]
+     (if (and (> self.life 0.08)
+              (> (neighbors> get (* (if (> self.life 0.9) 0.3 0.1) (math.random 7))) 0))
+         (do
+           (setmetatable {:life (* self.life 0.8)} (getmetatable self)))
+         nil))
+   cell.update
+   (fn [self get]
+     (if (> self.life 0.3)
+         (setmetatable {:life (* self.life (+ 0.5 (* (math.random 5) 0.1)))} (getmetatable self))
+         nil))
+   cell.aliveness
+   #$.life
+   cell.color
+   #[(+ 0.4 (* 0.6 $.life))
+     (math.max 0 (- 0.8 (* 0.9 (- 1 $.life))))
+     (+ 0.1 )]})
+
+{: life : brain : boom}