summaryrefslogtreecommitdiff
path: root/src/simulation/lattice_rules.test.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-11 15:10:55 -0600
committersanine <sanine.not@pm.me>2023-11-11 15:10:55 -0600
commitf995438c0e72e1d08203609d74854d07dbecd661 (patch)
treeb3e6c4f73526c61d9d6e5c4519b86fe0deaeb36f /src/simulation/lattice_rules.test.js
parentf7b0ed22b2fd0ddafc4a84dde1ad8e3208144844 (diff)
mutables can be activated by living neighbors
Diffstat (limited to 'src/simulation/lattice_rules.test.js')
-rw-r--r--src/simulation/lattice_rules.test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/simulation/lattice_rules.test.js b/src/simulation/lattice_rules.test.js
index 4b78116..7648a68 100644
--- a/src/simulation/lattice_rules.test.js
+++ b/src/simulation/lattice_rules.test.js
@@ -108,3 +108,34 @@ test("beehive", () => {
//expect(world_update(world).lattice).toEqual([
expect(apply(world_update, 1, world).lattice).toEqual(lattice);
});
+
+
+test("mutables are activated by neighboring actives", () => {
+ const L = { type: 'active', flags: {} };
+ const _ = { type: 'empty', flags: {} };
+ const l = { type: 'active', flags: { emit: [0, 0, 0, 0, 0, 0, 0, 1] } };
+ const d = { type: 'empty', flags: { emit: [0, 0, 0, 0, 0, 0, 0, -1] } };
+ const M = { type: 'mutable', flags: {} };
+
+ const lattice = [
+ [ _, _, _, _, ],
+ [ _, L, M, _, ],
+ [ _, M, M, _, ],
+ [ _, _, _, _, ],
+ ];
+
+ const world = { lattice, lattice_rules, agents: [], senses: [], actions: [], validity: [] };
+
+ expect(apply(world_update, 1, world).lattice).toEqual([
+ [ _, _, _, _, ],
+ [ _, L, l, _, ],
+ [ _, l, l, _, ],
+ [ _, _, _, _, ],
+ ]);
+ expect(apply(world_update, 2, world).lattice).toEqual([
+ [ _, _, _, _, ],
+ [ _, L, L, _, ],
+ [ _, L, L, _, ],
+ [ _, _, _, _, ],
+ ]);
+});