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));
+4
View File
@@ -3,6 +3,10 @@
"andrea": {
"speaker": "Andrew Chipper"
},
"giocatore_carte": {
"speaker": "Viktor Eka",
"filtro": "asetrate=24000*1.04,aresample=24000,atempo=0.98"
},
"vecchietta": {
"speaker": "Tammy Grit"
},
+12 -1
View File
@@ -25,7 +25,18 @@ if lavori:
import torch
import torchaudio
from TTS.api import TTS
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")
# Anche senza GPU (collaudo locale): XTTS_DEVICE=cpu, stesso modello e stesse voci.
device = os.environ.get("XTTS_DEVICE", "cuda")
if device == "cpu":
torch.set_num_threads(2)
model_dir = os.environ.get("XTTS_MODEL_DIR")
if model_dir:
# Modello già scaricato: nessun controllo di aggiornamenti in rete.
from TTS.utils.synthesizer import Synthesizer
tts = TTS()
tts.synthesizer = Synthesizer(model_dir=model_dir, use_cuda=device == "cuda")
else:
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
sr = tts.synthesizer.output_sample_rate
for i, j in enumerate(lavori, 1):
pezzi = []