summaryrefslogtreecommitdiff
path: root/src/simulation/lattice_rules.test.js
blob: a91400e0fb28ab96113e8c3a2e0ccdbeaa6e42ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
});