v0.4.4 — New Game dialog for the opening hand and the three revenue rates, Yard renamed Interchange, and two movement bugs behind a mirrored consist

This commit is contained in:
Jesse
2026-08-14 22:39:50 -04:00
parent d1314066bd
commit 6655e20ea8
29 changed files with 5450 additions and 3902 deletions
+30 -7
View File
@@ -21,7 +21,7 @@
* node src/sim/save-replay.ts 400 --top 3 trainCapSlack=0
*/
import { writeFileSync } from 'node:fs';
import { readdirSync, unlinkSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -131,13 +131,33 @@ if (isMain) {
` best ${revenues.slice(0, 5).join(', ')} · median ${revenues[Math.floor(revenues.length / 2)]}`,
);
let written = 0;
for (const p of best) {
const verified = best.filter((p) => {
const check = verifyReplays(p);
if (!check.ok) {
console.warn(` REFUSED seed ${p.seed} — ${check.why}`);
continue;
if (!check.ok) console.warn(` REFUSED seed ${p.seed} — ${check.why}`);
return check.ok;
});
/**
* THE PUBLISHED SET IS REPLACED, NOT ADDED TO.
*
* Every file here is named for its seed, so re-recording used to leave the previous set sitting
* beside the new one — and the previous set is precisely the one whose rules have just moved. The
* point of re-recording is that those files are dead; keeping them means the site serves dead
* replays and `harness.test.ts` fails on them forever, which is how the last two went unnoticed.
*
* Only ever run after at least one replacement verifies, so a run that produces nothing publishable
* leaves what is already published alone.
*/
if (verified.length > 0) {
for (const old of readdirSync(dest).filter((f) => f.endsWith('.json') && f !== 'manifest.json')) {
if (verified.some((p) => `seed-${p.seed}.json` === old)) continue;
unlinkSync(join(dest, old));
console.log(` retired ${old} — recorded under rules that have since moved`);
}
}
let written = 0;
for (const p of verified) {
const file = join(dest, `seed-${p.seed}.json`);
writeFileSync(
file,
@@ -148,13 +168,16 @@ if (isMain) {
// there is room — a title carrying seven tweak names is a title nobody reads.
title: `${p.revenue} Revenue · seed ${p.seed}`,
note: `${p.note} · played by ${policy.name}`,
// The house rules it was DEALT under, without which the seed does not name this game and
// the file replays as something else — see `Save.rules` in `web/game.ts`.
...(p.save.rules ? { rules: p.save.rules } : {}),
history: p.save.history,
},
null,
1,
),
);
console.log(` wrote ${file} (${p.note}, ${check.why})`);
console.log(` wrote ${file} (${p.note})`);
written += 1;
}
console.log(`${written} replay(s) saved — run \`npm run build:web\` to publish them`);