From 212948b1c4c5d10332d150ff69f6dbd567560ba9 Mon Sep 17 00:00:00 2001 From: mat ess Date: Mon, 12 Sep 2022 21:37:48 -0400 Subject: [PATCH] Add build instructions and make lurker optional --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ ants/main.lua | 4 +++- life/main.lua | 4 +++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..88d473c --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# cellular automata toys in löve2d + +## toys + +### ants + +langton's ant, heavily inspired by Andrew Healey's [blog post](https://healeycodes.com/virtual-ants) and [code](https://github.com/healeycodes/virtual-ants). + +supports multiple colors by passing a custom set of rules, see [wikipedia](https://en.wikipedia.org/wiki/Langton%27s_ant#Extension_to_multiple_colors). + +click on the screen to spawn new ants. + +### life + +conway's game of life. supports other life-like cellular automata rules, see [wikipedia](https://en.wikipedia.org/wiki/Life-like_cellular_automaton#A_selection_of_Life-like_rules) + +left click or click and drag to flip cells on, and right click to spawn a glider. + +## colorbrewer + +this repo includes a lua interface to [the lovely and accessible ColorBrewer2 colorschemes based on the research of Dr. Cynthia Brewer](https://colorbrewer2.org), based on [the original ColorBrewer code](https://github.com/axismaps/colorbrewer/) and the implementation in [Chroma.js](https://github.com/gka/chroma.js/). + +## running the toys + +if you have [löve](https://github.com/love2d/love) installed on your system, you can just run the toys by name: + +```bash +love ants +# run with a cool square pattern +love ants LRRRRRLLR +# other options +love ants + +love life +# run with HighLife rules +love life B36/S23 +# other options +love life +``` + +if you have [nix](https://nixos.org), you can use the provided flake.nix to get a working environment for running the games, as well as support for hot reloading if you want to hack on them. + +```bash +nix develop +love ... +``` diff --git a/ants/main.lua b/ants/main.lua index 7b668d1..8802217 100644 --- a/ants/main.lua +++ b/ants/main.lua @@ -132,7 +132,9 @@ function love.mousepressed(x, y) end function love.update() - require("lurker").update() + pcall(function() + require("lurker").update() + end) for _ = 1, STEPS_PER_FRAME do for i, ant in pairs(ANTS) do local c = nextColor(ant) diff --git a/life/main.lua b/life/main.lua index 39b8c60..b71f2fe 100644 --- a/life/main.lua +++ b/life/main.lua @@ -131,7 +131,9 @@ end FRAMELOCK_COUNTER = 0 FRAMELOCK_FPS = 30 function love.update(dt) - require("lurker").update() + pcall(function() + require("lurker").update() + end) FRAMELOCK_COUNTER = FRAMELOCK_COUNTER + dt if FRAMELOCK_COUNTER < (1 / FRAMELOCK_FPS) then return