feat: Doing more polishing (M8b)

This commit is contained in:
gauvainboiche
2026-10-25 18:50:17 +01:00
parent c2103c32e7
commit c55e5a2484
34 changed files with 1605 additions and 106 deletions
+7 -2
View File
@@ -11,7 +11,10 @@ import { STRATEGIES } from "../web/dev/sim-core.js";
const root = new URL("../web/data/", import.meta.url);
const read = (p) => JSON.parse(fs.readFileSync(new URL(p, root), "utf8"));
export const bal = read("balance.json");
export const scn = read("scenarios/default.json");
// --scenario <id> plays another scenario (default: "default")
const scenarioAt = process.argv.indexOf("--scenario");
export const scenarioId = scenarioAt > 0 ? process.argv[scenarioAt + 1] : "default";
export const scn = read(`scenarios/${scenarioId}.json`);
export const endgame = read("endgame.json");
// --set path=value (repeatable) overrides balance.json in memory, e.g. --set gain=2 --set indicators.opinion.drift=-1
@@ -323,6 +326,8 @@ const TARGETS = {
function check(seeds) {
let failures = 0;
// a scenario may ship its own bands (same shape as TARGETS), merged over the defaults
try { Object.assign(TARGETS, read(`scenarios/${scenarioId}.targets.json`).targets ?? {}); } catch { /* none */ }
for (const [name, want] of Object.entries(TARGETS)) {
const [b, p] = PLAYERS[name];
const runs = [];
@@ -343,7 +348,7 @@ function check(seeds) {
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replaceAll("\\", "/").split("/").pop())) {
const raw = process.argv.slice(2);
const args = raw.filter((a, i) => !a.startsWith("--") && raw[i - 1] !== "--set");
const args = raw.filter((a, i) => !a.startsWith("--") && raw[i - 1] !== "--set" && raw[i - 1] !== "--scenario");
const seeds = Number(args[0] ?? 12);
const names = args[1] ? args[1].split(",") : Object.keys(PLAYERS);
const t0 = Date.now();