Throughput in the info overlay: grains per second and backing-up glow (t49)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Throughput overlay (t49): grains per second per transport block, counted only while the
|
||||
// overlay is on, never changing what the simulation does.
|
||||
const { load, suite, flatWorld, rect } = require('./harness');
|
||||
const { run } = load();
|
||||
const { check, done } = suite();
|
||||
// A flat belt line fed from a sand heap, a screw line going right, and an uphill belt.
|
||||
function scene() {
|
||||
flatWorld(run, 240, 160, 140);
|
||||
run('RS = 7; nextPowerBuild = 0; bot.x = 120; bot.y = 60;');
|
||||
run('for (let bx = 10; bx < 20; bx++) placeBlock(BP_BELT, 1, bx, 30, true);');
|
||||
rect(run, 40, 100, 47, 119, run('SAND'));
|
||||
run('for (let bx = 30; bx < 38; bx++) placeBlock(BP_SCREW, 1, bx, 30, true);');
|
||||
rect(run, 120, 110, 123, 119, run('SAND'));
|
||||
run('for (let k = 0; k < 6; k++) placeBlock(BP_BELT_UP, 1, 44 + k, 30 - k, true); placeBlock(BP_BELT, 1, 43, 31, true);');
|
||||
rect(run, 172, 112, 175, 123, run('SAND'));
|
||||
}
|
||||
const hash = () => run('(() => { let h = 0; for (let i = 0; i < N; i++) h = (h * 31 + mat[i]) | 0; return h; })()');
|
||||
scene(); run('setFlowCounting(false); for (let k = 0; k < 300; k++) simTick();');
|
||||
const off = hash();
|
||||
scene(); run('setFlowCounting(true); for (let k = 0; k < 300; k++) simTick();');
|
||||
check('counting changes nothing in the simulation', hash() === off);
|
||||
const r = run('({ belt: flowRate[30 * BW + 15], beltEnd: flowRate[30 * BW + 19], screw: flowRate[30 * BW + 34], uphill: Math.max(...[0,1,2,3,4,5].map(k => flowRate[(30 - k) * BW + 44 + k])) })');
|
||||
check('a loaded flat belt reports grains per second', r.belt > 0, JSON.stringify(r));
|
||||
check('a loaded screw conveyor reports grains per second', r.screw > 0, JSON.stringify(r));
|
||||
check('an uphill belt carrying sand reports grains per second', r.uphill > 0, JSON.stringify(r));
|
||||
check('the rate is grains per second, not per tick (a flat belt moves well under 600)', r.belt < 600, JSON.stringify(r));
|
||||
scene(); run('setFlowCounting(false); for (let k = 0; k < 120; k++) simTick();');
|
||||
check('with the overlay off nothing is counted', run('flowCount.every(n => n === 0) && flowRate.every(n => n === 0)'));
|
||||
done();
|
||||
Reference in New Issue
Block a user