summaryrefslogtreecommitdiff
path: root/src/simulation/lattice_rules.test.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-09 16:46:33 -0600
committersanine <sanine.not@pm.me>2023-11-09 16:46:33 -0600
commit55b714abf83e01aa0ff513ad6ba4978f4b4da6cd (patch)
tree71518c2a6546681724f095424b755c2ab1ec8ecd /src/simulation/lattice_rules.test.js
parent819d8a51c5ba8b1bec06163dba9c3e0212f1120a (diff)
add basic game of life lattice rules
Diffstat (limited to 'src/simulation/lattice_rules.test.js')
-rw-r--r--src/simulation/lattice_rules.test.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/simulation/lattice_rules.test.js b/src/simulation/lattice_rules.test.js
new file mode 100644
index 0000000..a91400e
--- /dev/null
+++ b/src/simulation/lattice_rules.test.js
@@ -0,0 +1,25 @@
+import { world_update } from '../world/world.js';
+import { lattice_rules } from './lattice_rules.js';
+
+
+test("blinker", () => {
+ const L = { type: 'active', flags: {} };
+ const D = { type: 'empty', flags: {} };
+ const lattice = [
+ [ D, D, D, D, D ],
+ [ D, D, D, D, D ],
+ [ D, L, L, L, D ],
+ [ D, D, D, D, D ],
+ [ D, D, D, D, D ],
+ ];
+
+ const world = { lattice, lattice_rules, agents: [], senses: [], actions: [] };
+ expect(world_update(world).lattice).toEqual([
+ [ D, D, D, D, D ],
+ [ D, D, L, D, D ],
+ [ D, D, L, D, D ],
+ [ D, D, L, D, D ],
+ [ D, D, D, D, D ],
+ ]);
+ expect(world_update(world_update(world)).lattice).toEqual(lattice);
+});