31 lines
2.1 KiB
JavaScript
31 lines
2.1 KiB
JavaScript
// t105: compare every direction with the unchanged t45 belt and exercise the complete line.
|
|
const {kinds,speed,throughput,chain,fresh,run}=require('../tools/experiments/transport-balance');
|
|
const {suite}=require('./harness');
|
|
const {check,done}=suite();
|
|
for(const kind of kinds)for(const reverse of [false,true]){
|
|
const name=kind+(reverse?' mirrored':'');
|
|
if(kind==='screw-up-right'||kind==='screw-down-right') {
|
|
fresh(kind,reverse);
|
|
check(`${name}: both belt joins are mutual`,run(`(()=>{let n=0;for(let b=0;b<NB;b++)if(blockP[b]===BP_SCREW)for(let e=0;e<2;e++){const j=endJoin(b%BW,(b/BW)|0,e);if(j>=0&&blockP[j>>1]===BP_BELT)n++;}return n===2;})()`));
|
|
}
|
|
const v=speed(kind,reverse),bar=speed(kind,reverse,true);
|
|
const normal=throughput(kind,reverse,1),heavy=throughput(kind,reverse,16);
|
|
check(`${name}: grain path speed matches belt`,Math.abs(v-30)<=3,v);
|
|
check(`${name}: bar path speed matches belt`,Math.abs(bar-30)<=3,bar);
|
|
check(`${name}: normal feed matches belt`,Math.abs(normal-30)<=3,normal);
|
|
check(`${name}: heavy feed matches belt`,Math.abs(heavy-90)<=9,heavy);
|
|
}
|
|
fresh('screw-up-right',false);
|
|
run('placeBlock(BP_WALL,RSTONE,26,13,true);for(let k=0;k<1000;k++){transportFeed(ts,16);simTick();transportCollect(ts);}');
|
|
check('a blocked raised outlet holds its load and warns',run('transportStalled(15*BW+25)'));
|
|
run('removeBlock(26,13);');
|
|
const released=run('(()=>{let n=0;for(let k=0;k<600;k++){transportFeed(ts,16);simTick();n+=transportCollect(ts);}return n;})()');
|
|
check('clearing the raised outlet resumes delivery',released>0,released);
|
|
const line=chain();
|
|
check('mixed chain carries the full heavy belt feed',line.heavy>=89&&line.heavy<=91,JSON.stringify(line));
|
|
check('mixed chain has mutual diagonal joins',line.joined);
|
|
check('mixed chain conserves every supplied grain',line.added===line.accounted,`${line.added}/${line.accounted}`);
|
|
check('mixed chain spills no grains below its joins',line.stray===0,line.stray);
|
|
check('mixed chain has no growing piles at joins',line.late.every(([name,n],i)=>n<=line.early[i][1]+12),JSON.stringify(line.late));
|
|
done();
|