Domaine : match, niveau de l'ordinateur, événements en version 2
Partie de match (score et Crawford dits par le moteur), niveau choisi porté par GameStarted, ordinateur joué comme ComputerTurn de gnubg ; migration des journaux de la version 1 ; scénarios, glossaire, ADR 0007 et 0013 amendés. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c0f827c5ba
commit
339d699488
@@ -17,6 +17,7 @@ import type {
|
||||
CubeDecision,
|
||||
Engine,
|
||||
EngineCube,
|
||||
EngineMatch,
|
||||
EvaluatedMove,
|
||||
HalfMovesCheck,
|
||||
Level,
|
||||
@@ -75,13 +76,23 @@ export function createWasmEngine(run: RunCommand): Engine {
|
||||
const matchIds = new Map<string, string>();
|
||||
|
||||
async function matchId(cube: EngineCube): Promise<string> {
|
||||
// Partie libre, joueur 0 au trait : le propriétaire 0 est le joueur au
|
||||
// trait, 1 son adversaire, -1 le centre.
|
||||
// Joueur 0 au trait : le propriétaire 0 est le joueur au trait, 1 son
|
||||
// adversaire, -1 le centre ; le score 0 est le sien.
|
||||
const owner = { centered: -1, onRoll: 0, opponent: 1 }[cube.owner];
|
||||
const key = `${cube.value} ${owner}`;
|
||||
const args = ["matchid", String(cube.value), String(owner)];
|
||||
const match = cube.match;
|
||||
if (match !== undefined) {
|
||||
args.push(
|
||||
String(match.length),
|
||||
String(match.score.onRoll),
|
||||
String(match.score.opponent),
|
||||
match.crawford ? "1" : "0",
|
||||
);
|
||||
}
|
||||
const key = args.join(" ");
|
||||
let id = matchIds.get(key);
|
||||
if (id === undefined) {
|
||||
const answer = (await run(["matchid", String(cube.value), String(owner)])) as {
|
||||
const answer = (await run(args)) as {
|
||||
match_id: string;
|
||||
};
|
||||
id = answer.match_id;
|
||||
@@ -129,6 +140,32 @@ export function createWasmEngine(run: RunCommand): Engine {
|
||||
return toCubeDecision((await run(args)) as CliCubeDecision);
|
||||
},
|
||||
|
||||
async levelDouble(position: PositionId, cube: EngineCube, level: Level) {
|
||||
const args = ["--level", level, "double", position, await matchId(cube)];
|
||||
return ((await run(args)) as { double: boolean }).double;
|
||||
},
|
||||
|
||||
async levelTake(position: PositionId, cube: EngineCube, level: Level) {
|
||||
const args = ["--level", level, "take", position, await matchId(cube)];
|
||||
return ((await run(args)) as { take: boolean }).take;
|
||||
},
|
||||
|
||||
async matchAfterGame(match: EngineMatch, winner: "onRoll" | "opponent", points: number) {
|
||||
// Le joueur au trait est le joueur 0 du Match ID.
|
||||
const id = await matchId({ value: 1, owner: "centered", match });
|
||||
const answer = (await run([
|
||||
"aftergame",
|
||||
id,
|
||||
winner === "onRoll" ? "0" : "1",
|
||||
String(points),
|
||||
])) as { score: [number, number]; match_over: boolean; crawford: boolean };
|
||||
return {
|
||||
score: { onRoll: answer.score[0], opponent: answer.score[1] },
|
||||
over: answer.match_over,
|
||||
crawford: answer.crawford,
|
||||
};
|
||||
},
|
||||
|
||||
async analyseMove(
|
||||
position: PositionId,
|
||||
cube: EngineCube,
|
||||
|
||||
Reference in New Issue
Block a user