Metabolism: region pool — SharedArrayBuffer arena, band-parallel phases (block sums / VM decisions / advection+reaction), bit-identical to serial; 5.9x at 41k organisms; provider protocol sketched
This commit is contained in:
@@ -96,6 +96,25 @@ test('genesis pre-simulates generations so frame 0 is already an ecosystem', ()
|
||||
assert.equal(withGenesis.world.frame, -1, 'the film starts at frame 0');
|
||||
});
|
||||
|
||||
test('the region pool is exact: parallel == serial, bit for bit', () => {
|
||||
const grow = (workers) => {
|
||||
const song = load('drone');
|
||||
const run = new Run(song, { fps: 30, seed: 12345, width: 240, height: 135, field: 64, genesis: 0, workers });
|
||||
for (let f = 0; f < 150; f++) { run.world.step(); run.camera.update(f); }
|
||||
const history = Array.from(run.world.history.alive.slice(0, 150));
|
||||
const trail = Array.from(run.world.trail[0].slice(0, 4000));
|
||||
run.world.dispose?.();
|
||||
return { history, trail };
|
||||
};
|
||||
const serial = grow(0);
|
||||
const two = grow(2);
|
||||
const four = grow(4);
|
||||
const eq = (a, b) => a.history.every((v, i) => v === b.history[i]) &&
|
||||
a.trail.every((v, i) => v === b.trail[i]);
|
||||
assert.ok(eq(serial, two), '2 regions must match the serial world exactly');
|
||||
assert.ok(eq(serial, four), '4 regions must match the serial world exactly');
|
||||
});
|
||||
|
||||
test('genesis is deterministic and song-scaled', () => {
|
||||
const a = new Run(load('drone'), { fps: 30, seed: 12345, width: 240, height: 135, field: 64 });
|
||||
const b = new Run(load('drone'), { fps: 30, seed: 12345, width: 240, height: 135, field: 64 });
|
||||
|
||||
Reference in New Issue
Block a user