Prompts : le niveau du joueur seulement à partir de 20 décisions, son taux d'erreur dans le seul bilan
Recette de 1f (F3). En dessous de 20 décisions analysées, le prompt dit « Je débute au backgammon. ». Test du seuil ; outil prompt-sample pour relire des prompts remplis par le moteur. Plan de 1f clos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f509f8746e
commit
f2df1b2e7f
@@ -0,0 +1,82 @@
|
||||
// Affiche des prompts remplis sur de vraies analyses du moteur, pour les
|
||||
// relire (étape 1f) : node build/web/tests/tools/prompt-sample.js
|
||||
//
|
||||
// Copyright (C) 2026 les auteurs d'Ustagammon.
|
||||
// Licence : GPLv3 ou ultérieure (voir LICENSE).
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
import {
|
||||
missingAnalyses,
|
||||
runAnalysis,
|
||||
summarizeAnalysis,
|
||||
} from "../../src/domain/analysis/game-analysis.js";
|
||||
import type { Engine } from "../../src/domain/game/engine.js";
|
||||
import type { GameJournal } from "../../src/domain/game/events.js";
|
||||
import { Game } from "../../src/domain/game/game.js";
|
||||
import { positionBefore } from "../../src/domain/prompts/position.js";
|
||||
import {
|
||||
decisionPrompt,
|
||||
summaryPosition,
|
||||
summaryPrompt,
|
||||
} from "../../src/domain/prompts/prompts.js";
|
||||
import {
|
||||
PROMPT_FILES,
|
||||
type PromptTemplates,
|
||||
parsePromptTemplate,
|
||||
} from "../../src/domain/prompts/templates.js";
|
||||
import { adviceOn, loadPhrases, playOpening } from "../support/advice.js";
|
||||
import { loadNodeEngine } from "../support/node-engine.js";
|
||||
import { playToTheEnd, seededDice } from "../support/play.js";
|
||||
|
||||
const root = new URL("../../../../", import.meta.url);
|
||||
const read = (file: string) =>
|
||||
parsePromptTemplate(readFileSync(new URL(`docs/prompts/${file}`, root), "utf8"));
|
||||
const templates: PromptTemplates = {
|
||||
move: read(PROMPT_FILES.move),
|
||||
cube: read(PROMPT_FILES.cube),
|
||||
summary: read(PROMPT_FILES.summary),
|
||||
concept: read(PROMPT_FILES.concept),
|
||||
exercises: read(PROMPT_FILES.exercises),
|
||||
};
|
||||
const phrases = loadPhrases();
|
||||
const engine: Engine = await loadNodeEngine();
|
||||
|
||||
const played = await playOpening(engine, [3, 1], "24/23 13/10");
|
||||
const advice = await adviceOn(engine, played);
|
||||
played.game.recordAdvice(advice);
|
||||
const position = await positionBefore(engine, played.game.journal, played.eventId);
|
||||
console.log(decisionPrompt(templates, phrases, { journal: played.game.journal, advice, position }));
|
||||
|
||||
async function analyseAll(journal: GameJournal): Promise<GameJournal> {
|
||||
let current = journal;
|
||||
for (;;) {
|
||||
const next = missingAnalyses(current)[0];
|
||||
if (next === undefined) {
|
||||
return current;
|
||||
}
|
||||
current = await runAnalysis(engine, current, next);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [seed, choice] of [
|
||||
[7, 1],
|
||||
[7, 2],
|
||||
[11, 2],
|
||||
[3, 3],
|
||||
]) {
|
||||
const game = Game.start(engine, {
|
||||
setup: { position: "trsXAADs7mwAAA", firstTurn: "player" },
|
||||
level: "intermediate",
|
||||
dice: seededDice(seed ?? 0),
|
||||
});
|
||||
await playToTheEnd(game, engine, choice);
|
||||
const journal = await analyseAll(game.journal);
|
||||
const summary = summarizeAnalysis(journal);
|
||||
console.log(
|
||||
`\n=== graine ${seed}, choix ${choice} : coup à revoir ${summary.toReview?.turn ?? "aucun"}`,
|
||||
);
|
||||
if (seed === 3) {
|
||||
const where = await summaryPosition(engine, journal);
|
||||
console.log(summaryPrompt(templates, phrases, { journal, position: where }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user