Files
Aislo/resources/tester/helper_stmate_kanjub_loop.cjs
T

31 lines
1.2 KiB
JavaScript

// STMATE 재현 앱 요율 순환 점검·수동 확정(scr_kanjub_rate.js) — stdin {matrix, scales} · 규모를 차례로 돌려 순환을 만듦
const R = require("../../tools/stmate-test/scr_kanjub_rate.js");
let buf = "";
process.stdin.setEncoding("utf8");
process.stdin.on("data", (d) => (buf += d));
process.stdin.on("end", () => {
const { matrix, scales } = JSON.parse(buf);
const m = R.matrixFromRows(matrix);
const cfg = { keys: {}, rates: {} };
let i = 0;
const calc = () => ({ dT: scales[i++ % scales.length], anjunBaseRaw: 0 });
const first = R.applyWithLoopCheck(cfg, m, calc);
const picked = first.choices && first.choices[first.choices.length - 1];
if (picked) R.confirmManual(cfg, picked);
const ratesAfterPick = Object.assign({}, cfg.rates);
const again = R.applyWithLoopCheck(cfg, m, calc);
const keep = JSON.stringify(cfg.rates) === JSON.stringify(ratesAfterPick);
R.clearManual(cfg);
const freed = R.applyWithLoopCheck(cfg, m, calc);
process.stdout.write(
JSON.stringify({
loop: first.loop,
choices: (first.choices || []).map((c) => c.band.name),
pickedBand: picked && picked.band.name,
againManual: !!again.manual,
keep,
freedLoop: freed.loop,
}),
);
});