Recette de 1k : dé barré dès le lancer, règle de gnubg sur l'abandon refusé, phrases, ordre des dés

- Dé injouable : une valeur absente de tous les coups légaux du moteur est
  barrée dès le lancer ; consignes « Rentrez un pion avec le 6. » puis
  « Jouez votre coup. ».
- Abandon refusé : le genre refusé, ou plus petit, est grisé « déjà
  refusé » (fResignationDeclined, play.c l. 2345 et 4026-4033) ; plus de
  drapeau quand rien ne reste.
- Phrases abandon.refus et abandon.accepte, introduction de la feuille,
  note Jacoby et choix présélectionné.
- Fin par abandon : une seule phrase ; bilan sans coup : « Aucun coup
  joué : rien à analyser. ».
- Jets écrits le plus grand dé d'abord (formatRoll).
- Match en SGF avec une partie abandonnée, relu par gnubg ; bilan du match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-23 08:17:00 +01:00
co-authored by Claude Opus 5.5
parent fc29bc65b5
commit 57b80c0d07
22 changed files with 545 additions and 189 deletions
+3 -2
View File
@@ -1415,8 +1415,9 @@ for (let actions = 0; ; actions++) {
check(last?.type === "DiceRolled" && (await page.isEnabled("#cancel")),
`coup complet déjà joué ou non annulable (dernier événement ${last?.type})`);
// Avec un dé devenu injouable (étape 1k), la consigne dit pourquoi
// et invite à finir son tour.
check(/jouer ce coup|finir votre tour/i.test((await page.textContent("#prompt")) ?? ""),
// et invite à jouer son coup.
check(/jouer ce coup|jouez votre coup|ne peut pas se jouer|ne peuvent pas se jouer|se joue/i.test(
(await page.textContent("#prompt")) ?? ""),
`consigne de validation absente : « ${await page.textContent("#prompt")} »`);
const dice = await shownDice();
check(dice.used === halfMoves && dice.used > 0,
+72 -26
View File
@@ -193,7 +193,7 @@ await capture("1-drapeau", flagShown);
await page.click("#resign");
await until("feuille d'abandon", () => !document.getElementById("resign-veil").hidden);
s = await resignState();
check(s.lead === "Vous proposez de perdre tout de suite. L'ordinateur accepte ou refuse, selon le moteur. Le videau est à 2.",
check(s.lead === "Vous proposez de perdre tout de suite. L'ordinateur accepte s'il n'espère pas mieux en continuant. Le videau est à 2.",
`phrase de la feuille : « ${s.lead} »`);
check(JSON.stringify(s.choices.map((c) => [c.kind, c.text, c.radio, c.checked])) === JSON.stringify([
["single", "Une partie simple2 points", true, "true"],
@@ -210,7 +210,7 @@ await page.click("#resign-confirm");
await until("réponse de l'ordinateur", () =>
document.getElementById("resign-veil").hidden && !document.body.classList.contains("busy"));
s = await resignState();
check(s.refusal === "L'ordinateur refuse. D'après le moteur, il peut espérer plus qu'une partie simple en continuant. La partie continue.",
check(s.refusal === "L'ordinateur refuse : il espère gagner plus qu'une partie simple en continuant. La partie continue.",
`message du refus : « ${s.refusal} »`);
check(s.roll && s.flag && s.panel === null, `après le refus, la partie continue : ${JSON.stringify(s)}`);
await capture("3-abandon-refuse", async (size) => {
@@ -222,11 +222,21 @@ await capture("3-abandon-refuse", async (size) => {
// ------------------------------------------ Le gammon : accepté
// Après le refus (règle de gnubg, fResignationDeclined) : la partie simple
// est grisée, « déjà refusé », et le gammon présélectionné.
await page.click("#resign");
await until("feuille d'abandon", () => !document.getElementById("resign-veil").hidden);
await page.click('#resign-choices [data-kind="gammon"]');
s = await resignState();
check(s.choices.find((c) => c.kind === "gammon")?.checked === "true", `gammon choisi : ${JSON.stringify(s.choices)}`);
const declined = await page.evaluate(() =>
document.querySelector('#resign-choices [data-kind="single"]').disabled);
check(declined && JSON.stringify(s.choices.map((c) => [c.kind, c.text, c.checked])) === JSON.stringify([
["single", "Une partie simpledéjà refusé", "false"],
["gammon", "Un gammon4 points", "true"],
["backgammon", "Un backgammon6 points", "false"],
]), `feuille après le refus : ${JSON.stringify(s.choices)}`);
await capture("3b-feuille-apres-refus", async () => {
check((await resignState()).sheet, "la feuille s'est fermée en changeant de taille");
});
await page.click("#resign-confirm");
// Le panneau de fin, puis le bilan à sa place dès que l'analyse est prête :
// entre les deux, ni l'un ni l'autre un court instant.
@@ -237,28 +247,56 @@ await until("fin de partie", (title) =>
document.getElementById("summary-title")?.textContent === title),
"Perdue par abandon, gammon, 4 points");
check(await page.isHidden("#resign"), "drapeau après la fin");
// Le bilan, une fois l'analyse prête, dit aussi l'abandon.
// Le bilan, une fois l'analyse prête : aucun coup, une seule phrase.
await until("bilan prêt", () => !document.getElementById("summary-veil").hidden &&
document.getElementById("summary")?.dataset.ready === "true", null, 120_000);
const summaryTitle = await page.textContent("#summary-title");
check(summaryTitle === "Perdue par abandon, gammon, 4 points", `bilan : « ${summaryTitle} »`);
const bilan = await page.evaluate(() => ({
title: document.getElementById("summary-title")?.textContent,
reading: document.getElementById("summary-reading")?.textContent,
counts: document.getElementById("summary-counts") !== null,
gauges: document.querySelector("#summary .summary-gauges") !== null,
}));
check(bilan.title === "Perdue par abandon, gammon, 4 points" &&
bilan.reading === "Aucun coup joué : rien à analyser." && !bilan.counts && !bilan.gauges,
`bilan sans coup : ${JSON.stringify(bilan)}`);
await capture("5-bilan-abandon");
// Le bilan fermé laisse la partie finie à l'écran, avec son résultat.
// Le bilan fermé laisse la partie finie à l'écran : une seule phrase, celle
// du maître, dans le style de l'état de la partie.
await page.click("#summary-close");
await until("partie finie à l'écran", () => location.hash === "#/" &&
document.getElementById("summary-veil").hidden &&
document.getElementById("prompt").textContent.startsWith("Perdue par abandon, gammon, 4 points"));
document.getElementById("prompt").textContent === "L'ordinateur accepte : vous perdez un gammon, 4 points.");
const ending = await page.evaluate(() => ({
neutral: document.getElementById("prompt").classList.contains("neutral"),
info: document.getElementById("info").textContent,
}));
check(!ending.neutral && !ending.info.includes("accepte"), `fin par abandon, une seule phrase : ${JSON.stringify(ending)}`);
await capture("4-abandon-accepte");
// ------------------------- Partie libre, videau au centre : Jacoby
await startFrom(ATTACKED);
// « Doubler », à côté du drapeau : une zone de toucher d'au moins 44 px de
// haut, un libellé jamais coupé (recette, 412 px de large).
const doubleButton = await page.evaluate(() => {
const b = document.getElementById("double");
const r = b.getBoundingClientRect();
return { shown: !b.hidden, height: r.height, clipped: b.scrollWidth > b.clientWidth + 0.5 };
});
check(doubleButton.shown && doubleButton.height >= 44 && !doubleButton.clipped,
`« Doubler » à côté du drapeau : ${JSON.stringify(doubleButton)}`);
await page.click("#resign");
await until("feuille d'abandon", () => !document.getElementById("resign-veil").hidden);
s = await resignState();
check(JSON.stringify(s.choices.map((c) => [c.kind, c.text, c.radio])) ===
JSON.stringify([["single", "Une partie simple1 point", false]]),
`Jacoby : la partie simple seule, sans liste : ${JSON.stringify(s.choices)}`);
check(JSON.stringify(s.choices.map((c) => [c.kind, c.text, c.radio, c.checked])) ===
JSON.stringify([["single", "Une partie simple1 point", true, "true"]]),
`Jacoby : la partie simple seule, présélectionnée : ${JSON.stringify(s.choices)}`);
const note = await page.evaluate(() => {
const n = document.getElementById("resign-note");
return n.hidden ? null : n.textContent;
});
check(note === "Le videau n'a pas été doublé : gammon et backgammon ne comptent pas (règle Jacoby).",
`Jacoby : la note « ${note} »`);
await capture("6-feuille-jacoby");
await page.click("#resign-cancel");
await until("feuille fermée", () => document.getElementById("resign-veil").hidden);
@@ -288,31 +326,39 @@ for (let tries = 0; tries < 40 && other === null; tries++) {
}
}
check(other !== null, "aucun jet avec un seul 6 en 40 essais");
await page.click('.hit.can-move[data-place="bar-player"]');
if ((await page.locator(".hit.can-land").count()) > 0) {
await page.click(".hit.can-land");
}
await until("dé injouable", () => !document.body.classList.contains("busy") &&
document.querySelector("#board .die-blocked") !== null);
const blocked = await page.evaluate(() => ({
const point = 25 - other;
const blockedDie = () => page.evaluate(() => ({
labels: [...document.querySelectorAll("#board .die-blocked")].map((d) => d.getAttribute("aria-label")),
strikes: document.querySelectorAll("#board .die-blocked .die-strike").length,
prompt: document.getElementById("prompt").textContent,
}));
// Dès le lancer, le dé qui ne rentre pas est barré (il n'apparaît dans aucun
// coup légal du moteur).
let blocked = await blockedDie();
check(JSON.stringify(blocked.labels) === JSON.stringify([`${other} : ne peut pas être joué`]) &&
blocked.strikes === 1, `dé injouable : ${JSON.stringify(blocked)}`);
const point = 25 - other;
blocked.strikes === 1, `dé injouable dès le lancer : ${JSON.stringify(blocked)}`);
// La forme longue de la consigne (les trois premières parties), ou la courte.
check(blocked.prompt === `Votre ${other} ne peut pas être joué : la flèche ${point} est fermée, ` +
"votre pion ne peut pas rentrer. Touchez les dés pour finir votre tour." ||
blocked.prompt === `Flèche ${point} fermée : touchez les dés.`,
`consigne du dé injouable : « ${blocked.prompt} »`);
const short = `Le ${other} ne peut pas se jouer : flèche ${point} fermée.`;
check(blocked.prompt === `Le ${other} ne peut pas se jouer : la flèche ${point} est fermée. ` +
"Rentrez un pion avec le 6." || blocked.prompt === short,
`consigne du dé injouable, au lancer : « ${blocked.prompt} »`);
await capture("8-de-injouable", async (size) => {
if (size.width > size.height) {
const band = await page.evaluate(() => document.getElementById("band-text")?.textContent ?? "");
check(band === `Flèche ${point} fermée : touchez les dés.`, `bande du dé injouable : « ${band} »`);
check(band === short, `bande du dé injouable : « ${band} »`);
}
});
await page.click('.hit.can-move[data-place="bar-player"]');
if ((await page.locator(".hit.can-land").count()) > 0) {
await page.click(".hit.can-land");
}
await until("pion rentré", () => !document.body.classList.contains("busy") &&
!document.getElementById("confirm").hidden);
blocked = await blockedDie();
check(blocked.labels.length === 1 && (blocked.prompt === `Le ${other} ne peut pas se jouer : la flèche ${point} ` +
"est fermée. Jouez votre coup." || blocked.prompt === short),
`consigne du dé injouable, après le 6 : « ${blocked.prompt} »`);
await capture("8b-de-injouable-apres");
// --------------------------------------------- Match en 7 points