Briscola all'oratorio: alle tavolate il giocatore di carte (segnaposto, sprite di Codex) sfida Andrea a briscola in due. Si sceglie il mazzo, toscane (cuori, mattoni, fiori, picche; gobbo, donna e regio) o napoletane, e il livello: «Alla bona», «Seria», «A fassi male» (conta le carte uscite, finale perfetto a mazzo finito, mai la mano altrui). Regole fedeli, conteggio delle prese a fine partita, rivincita, suoni di carte, comandi con mouse, tocco e tastiera. Carte e dorso col Regolo serpentello disegnati da Codex; motore e prove nel browser rivisti da Claude

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A1dxvtsZx8NE9fwjXUNDBr
This commit is contained in:
2026-10-26 13:56:39 +01:00
co-authored by Claude Opus 5.5
parent 2362fc7741
commit 92e7a289be
41 changed files with 1361 additions and 34 deletions
+25
View File
@@ -0,0 +1,25 @@
// node tools/calibrate_briscola.mjs [partite per livello, predefinite 1000]
// Stessi semi e mazzi per i tre livelli; Andrea gioca con l'euristica «attenta».
import { newBriscola, observation, attentive, play, update, canPlay, LEVELS } from '../src/engine/briscola.js';
export function simulate(seed, level) {
const c = newBriscola(seed, { level });
for (let steps = 0; steps < 200 && c.step !== 'result'; steps++) {
if (canPlay(c)) play(c, attentive(observation(c, 'player')));
update(c, 20); c.events.length = 0;
}
if (c.step !== 'result') throw new Error('Partita non conclusa');
return c;
}
export function calibrate(n = 1000) {
return LEVELS.map(level => {
const wins = { player: 0, cpu: 0, draw: 0 };
let sum = 0, dealers = 0;
for (let i = 1; i <= n; i++) {
const c = simulate(Math.imul(i, 2654435761) >>> 0, level);
wins[c.result.winner ?? 'draw']++; sum += c.result.player; dealers += c.dealer === 'player';
}
return { level, games: n, wins, playerPercent: 100 * wins.player / n, drawPercent: 100 * wins.draw / n, average: sum / n, playerDeals: dealers };
});
}
if (process.argv[1] === new URL(import.meta.url).pathname) console.log(JSON.stringify(calibrate(Number(process.argv[2]) || 1000), null, 2));