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
26
27
28
29
30
31
32
33
34
35
36
37
|
'use strict';
import { world_update } from '../world/world.js';
import { postprocess } from './postprocess.js';
test("agents freeze when finishing on a mutable or active", () => {
const agent = {
id: 1,
net: { compute: () => [[1], null] },
state: null,
x: 0, y: 0,
flags: {},
};
const lattice = [[{ type: 'empty', flags: {} }]];
const world = {
lattice,
lattice_rules: { empty: ()=>{}, active: ()=>{}, mutable: ()=>{} },
agents: [agent],
senses: [],
actions: [],
validity: [],
};
expect(world_update(world, postprocess).agents[0]).toEqual(agent);
world.lattice[0][0].type = 'mutable';
expect(world_update(world, postprocess).agents[0]).toEqual({
...agent,
flags: { frozen: true },
});
world.lattice[0][0].type = 'active';
expect(world_update(world, postprocess).agents[0]).toEqual({
...agent,
flags: { frozen: true },
});
});
|