From ca870dab91daee38b8d55ac6d2f2b4fd6959c6ac Mon Sep 17 00:00:00 2001 From: equa Date: Sun, 18 Apr 2021 20:22:20 -0500 Subject: entities et al --- lib/cells.fnl | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/cells.fnl') 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} -- cgit 1.3.0-6-gf8a5