Remove the Refiner and Stone cutter; old saves refund them on load (t4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 16:39:27 -04:00
co-authored by Claude Opus 5.5
parent 8d9e9c546b
commit f4eddfb82b
12 changed files with 70 additions and 152 deletions
+20 -9
View File
@@ -1,4 +1,4 @@
// Uses for waste rock and sand: glass bricks from a fan furnace, the stone cutter, the silo and
// Uses for waste rock and sand: glass bricks from a fan furnace, the Saw, the silo and
// builders' orders.
const { load, suite, flatWorld, count } = require('./harness');
const { run } = load();
@@ -31,15 +31,11 @@ check('opening space below drops glass bricks', bars(run('BARGL')) >= 2 && run('
check('glass bricks sell for much more than the sand in them', run('PRICE[BARGL]') >= 8 * run('PRICE[SAND]') * 10, run('PRICE[BARGL]'));
check('glass in a bit mold is too brittle to make a bit', run("METAL_TIER[GLASS]") === 0);
// ---- the stone cutter: 8 rubble to a stone brick; other grains drop through
// ---- Saw bricks ride a belt and build walls
flatWorld(run, 240, 160, 100);
run("money = 9999; bot.x = 60; bot.y = 40; stats.bricks = 0; placeMachineAt('cutter', 0, 26, 18); for (let bx = 24; bx <= 34; bx++) placeBlock(BP_BELT, 1, bx, 21, true);"); // x 104..111, y 72..79; out at y 80, onto a belt
run('for (let y = 72; y < 77; y++) for (let x = 106; x < 110; x++) setCell(y * W + x, RSTONE, AMB[y], 0);'); // 20 grains
for (let k = 0; k < 4; k++) { run('for (let k = 0; k < 150; k++) simTick();'); run('for (let y = 72; y < 77; y++) for (let x = 106; x < 110; x++) if (mat[y * W + x] === EMPTY) setCell(y * W + x, RSTONE, AMB[y], 0);'); }
run('for (let k = 0; k < 300; k++) simTick();');
const fed = run('stats.bricks') * 8 + run("machines.find(m => m && m.type === 'cutter').cut");
check('the stone cutter turns every 8 rubble into a stone brick', bars(run('BARSB')) === run('stats.bricks') && run('stats.bricks') >= 8 && count(run, run('RSTONE'), 104, 72, 111, 79) === 0, `${bars(run('BARSB'))} bricks from ${fed} rubble`);
check('and they ride a belt away from under it', run('ents.filter(e => e.m === BARSB && e.ix > 120).length') >= 3, run('JSON.stringify(ents.filter(e => e.m === BARSB).map(e => e.ix))'));
run("money = 9999; bot.x = 60; bot.y = 40; stats.bricks = 0; placeBlock(BP_SAW, 0, 26, 19, true); for (let bx = 24; bx <= 34; bx++) placeBlock(BP_BELT, 1, bx, 21, true);");
run('for (let k = 0; k < 100; k++) { setCell(75 * W + 104, RSTONE, AMB[75], 0); stamp[75 * W + 104] = 0; for (let t = 0; t < 4; t++) { tick++; tickStamp++; procBlocksTick(); } for (let t = 0; t < 10; t++) simTick(); } for (let k = 0; k < 300; k++) simTick();');
check('Saw bricks ride a belt away from under it', run('ents.filter(e => e.m === BARSB && e.ix > 120).length') >= 3, run('JSON.stringify(ents.filter(e => e.m === BARSB).map(e => e.ix))'));
check('stone bricks build cut stone walls, 2 a block', run('WALL_OF[BARSB]') === run('CUTST') && JSON.stringify(run('wallCost(BARSB, 16)')) === JSON.stringify([[run('BARSB'), 2]]));
check('cut stone stands more heat than rough stone', run('MELT[CUTST]') > run('MELT[STONE]'));
run('bag[BARSB] = 4; bagTotal = 4; placeBlock(BP_WALL, BARSB, 10, 20, false);');
@@ -100,6 +96,21 @@ hopper('BP_SAW'); feedHopper('RSTONE', 3);
run('(() => { const s = serializeWorld(); deserializeWorld(s.meta, s.buffers); })(); procBlocksTick();');
check('loading rebuilds processors and drops partial brick state', run('procBlocks.length === 1 && procState.get(18*BW+20).cut === 0 && SAVE_VERSION === 2'));
// ---- removed machines in old saves are refunded and leave no hull or machine ids
flatWorld(run, 240, 160, 100);
run("money = 1000; addMachine('fan', 10, 10, 0); placeDock(160);");
for (const [type, refund] of [['refiner', 120], ['cutter', 90], ['unknown', 0]]) {
const result = run(`(() => {
const saved = serializeWorld(), meta = JSON.parse(JSON.stringify(saved.meta));
const before = machines.filter(Boolean).length, cash = money;
meta.machines.push({ type: '${type}', bx: 20, by: 10, dir: 0, on: true });
saved.buffers.mat[40 * W + 80] = HULL;
deserializeWorld(meta, saved.buffers);
return [machines.filter(Boolean).length === before, money - cash, mat[40 * W + 80] === EMPTY && mach[40 * W + 80] === 0];
})()`);
check(`loading a saved ${type} skips it and refunds exactly $${refund}`, result[0] && result[1] === refund && result[2], result);
}
// ---- builders' orders: bulk rubble, gravel and stone bricks at a few times a tiny price
flatWorld(run, 240, 160, 100);
run('seen[RSTONE] = 1; seen[GRAVEL] = 1; seen[BARSB] = 1; orders = []; ordersDone = 0;');