Fusion de main (analyse du match, 1l) ; l'abandon passe en version 4 des événements

La version 3 est celle de main (identifiant de match) ; l'abandon prend la
version 4, avec la migration des versions 1, 2 et 3 testée.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-23 08:03:02 +01:00
co-authored by Claude Opus 5.5
74 changed files with 5232 additions and 156 deletions
+1
View File
@@ -37,6 +37,7 @@ const templates: PromptTemplates = {
summary: read(PROMPT_FILES.summary),
concept: read(PROMPT_FILES.concept),
exercises: read(PROMPT_FILES.exercises),
match: read(PROMPT_FILES.match),
};
const phrases = loadPhrases();
const engine: Engine = await loadNodeEngine();
+41 -2
View File
@@ -15,8 +15,9 @@
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { Game } from "../../src/domain/game/game.js";
import { exportSgf } from "../../src/domain/game/sgf.js";
import { Game, type NewGame } from "../../src/domain/game/game.js";
import { firstGameOf } from "../../src/domain/game/match.js";
import { exportMatchSgf, exportSgf } from "../../src/domain/game/sgf.js";
import { loadNodeEngine } from "../support/node-engine.js";
import { playMoves, playToTheEnd, seededDice, step } from "../support/play.js";
@@ -171,6 +172,44 @@ async function main(): Promise<void> {
}
game.goBackTo(original.head as string);
}
// Un match entier en 3 points (étape 1l), exporté d'un seul fichier :
// chaque partie à la suite, avec son numéro et le score avant elle. La
// première graine dont le match compte au moins trois parties.
for (let seed = 21; ; seed++) {
const dice = seededDice(seed);
const played: Game[] = [];
let next: Game | null = Game.start(engine, {
dice,
level: "0ply",
match: firstGameOf(3, "exemple"),
});
while (next !== null) {
await playToTheEnd(next, engine);
played.push(next);
const following: NewGame | null = next.nextGame;
next = following === null ? null : Game.start(engine, { ...following, dice });
}
if (played.length < 3) {
continue;
}
const sgf = await exportMatchSgf(
engine,
played.map((g) => g.journal),
{ playerName: "Vous", computerName: "Ordinateur", date: "2026-11-12" },
);
const expected = {
length: 3,
games: played.map((g) => ({
after: g.events.flatMap((e) => (e.type === "MovePlayed" ? [e.position] : [])),
result: g.state.result,
score: g.state.match?.score,
})),
};
writeFileSync(join(out, `match-${seed}.sgf`), sgf);
writeFileSync(join(out, `match-${seed}.json`), `${JSON.stringify(expected)}\n`);
files++;
break;
}
console.log(`${files} parties exportées dans ${out}`);
}