Build range follows the screen; out-of-range replace ghosts replace (t64)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,4 +79,29 @@ run('for (let y = 120; y < 122; y++) for (let x = 60; x < 62; x++) setCell(y * W
|
||||
const n = run('clearHardSpecks(true)');
|
||||
check('a 4-grain speck of iron ore in stone becomes stone; a 100-grain vein stays', n === 1 && count(run, run('FEV')) === 100 && run('mat[120 * W + 60]') === run('STONE'), `${n} specks, ${count(run, run('FEV'))} vein`);
|
||||
|
||||
// t64: building reaches about as far as the screen shows, and a replace placed out of range
|
||||
// becomes a ghost that replaces the old piece when the bot comes in range.
|
||||
fresh();
|
||||
check('with no view the build range is a REACH box around the bot', run('buildBox = null; inBuildRange(bot.x + bot.w / 2 + REACH, bot.y) && !inBuildRange(bot.x + bot.w / 2 + REACH + 2, bot.y)'));
|
||||
check('the build range follows the view box', run('(() => { setBuildRange(200, 100, 300, 160); const r = inBuildRange(340, 100) && !inBuildRange(352, 100) && inBuildRange(200, 180) && !inBuildRange(200, 190); buildBox = null; return r; })()'));
|
||||
check('a tiny view still reaches REACH and a huge one stops at BUILD_MAX', run('(() => { setBuildRange(500, 500, 20, 20000); const r = buildBox.hw === REACH && buildBox.hh === BUILD_MAX; buildBox = null; return r; })()'));
|
||||
fresh();
|
||||
const swap = run(`(() => {
|
||||
placeBlock(BP_BELT, 1, 50, 20, true); const b = 20 * BW + 50, m0 = money;
|
||||
ghostBlocks.set(b, [BP_SCREW, 1, undefined, 1]);
|
||||
bot.x = 20; bot.y = 20; for (let k = 0; k < 30; k++) ghostTick();
|
||||
const before = blockP[b];
|
||||
bot.x = 50 * BS - 4; bot.y = 20 * BS - 10; for (let k = 0; k < 30; k++) ghostTick();
|
||||
return { before, after: blockP[b], v: blockV[b], spent: m0 - money, ghosts: ghostBlocks.size };
|
||||
})()`);
|
||||
check('an out-of-range replace ghost leaves the old piece until the bot comes near', swap.before === run('BP_BELT'), JSON.stringify(swap));
|
||||
check('then replaces it: the new piece is built and the ghost is gone', swap.after === run('BP_SCREW') && swap.v === 1 && swap.ghosts === 0, JSON.stringify(swap));
|
||||
check('the replace charges the new piece and refunds the old one', swap.spent === 25 - 12, JSON.stringify(swap));
|
||||
fresh();
|
||||
check('a plain ghost over a different piece still leaves it alone', run(`(() => {
|
||||
placeBlock(BP_BELT, 1, 30, 20, true); const b = 20 * BW + 30;
|
||||
ghostBlocks.set(b, [BP_SCREW, 1]); bot.x = 30 * BS - 4; bot.y = 20 * BS - 10;
|
||||
for (let k = 0; k < 30; k++) ghostTick();
|
||||
return blockP[b] === BP_BELT && ghostBlocks.has(b);
|
||||
})()`));
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user