// The starter furnaces keep working when fired again and again without cleaning, however // the charge goes in: mixed, ore first with coal on top, or blown in through the vent. // Each case plays furnace_play.js, which builds the design and fires it like a player. const { execFileSync } = require('child_process'); const { suite } = require('./harness'); const { check, done } = suite(); function play(design, ore, coal, firings, roll, mode) { const out = execFileSync('node', [__dirname + '/furnace_play.js', design, ore, coal, firings, roll, mode].map(String), { encoding: 'utf8', timeout: 600000 }); const per = [...out.matchAll(/firing \d+: (.*)\| bars (\d+) \| left in furnace: ore (\d+), coal (\d+), slag (\d+), ash (\d+)/g)] .map(r => ({ bit: /New drill bit/.test(r[1]), bars: +r[2], ore: +r[3], coal: +r[4], slag: +r[5], ash: +r[6] })); return per; } for (const mode of ['mix', 'layers', 'vent']) { const runs = [0, 1].map(k => play('smelter1', 50, 50, 6, k, mode)); const bars = runs.map(r => r.reduce((s, f) => s + f.bars, 0)); const last = runs.map(r => r[r.length - 1]); check(`copper smelter, ${mode}: about 3 bars every firing for 6 firings`, bars.every(b => b >= 16), bars.join(', ') + ' of 18'); check(` and the furnace stays clean`, last.every(f => f.ore < 30 && f.slag + f.ash < 10), last.map(f => `ore ${f.ore} slag ${f.slag} ash ${f.ash}`).join('; ')); } for (const mode of ['mix', 'layers', 'vent']) { const got = [0, 1, 2].map(k => play('bitfurnace', 70, 70, 2, k, mode).filter(f => f.bit).length); check(`bit furnace, ${mode}: makes a bit every firing`, got.reduce((s, n) => s + n, 0) >= 5, got.join(', ') + ' of 2 each'); } done();