Moteur : abandon proposé, réponse de l'ordinateur comme gnubg de bureau

Porte dans engine.c la décision de gnubg 1.08.003 (play.c l. 951-975 et
1074-1097, rollout.c l. 1754-1815), l'expose par engine.h et engine-cli
(commande resign), et ajoute sept abandons de référence comparés à gnubg
de bureau (make reference).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-13 00:37:19 +01:00
co-authored by Claude Opus 5.5
parent da9845466b
commit e98497e5b1
16 changed files with 539 additions and 8 deletions
+41 -1
View File
@@ -50,6 +50,12 @@
* no_double ou double (joueur au trait),
* take ou pass (son adversaire)
* luck POSITION_ID MATCH_ID DÉS chance du jet pour le joueur au trait
* resign POSITION_ID MATCH_ID abandon du joueur au trait, avant de
* lancer les dés : pour une partie
* simple, un gammon et un backgammon,
* choix proposé, points concédés et
* réponse de l'ordinateur (comme gnubg
* de bureau)
*
* --ply : niveau de gnubg, de 0 (défaut) à 4 (meilleur coup comme « hint »,
* analyses comme l'analyse de partie de gnubg).
@@ -83,7 +89,7 @@
/* Liste des commandes, pour les messages d'erreur. */
#define COMMANDS "bestmove, moves, legal, cube, eval, position, halfmoves, matchid, reference, " \
"levels, analysemove, analysecube, luck, double, take ou aftergame"
"levels, analysemove, analysecube, luck, resign, double, take ou aftergame"
/* Coups gardés dans le classement de la commande reference (comme hint). */
#define REFERENCE_MAX_MOVES 10
@@ -776,6 +782,38 @@ run_luck_command(const options *opt)
return EXIT_SUCCESS;
}
/* Genres d'abandon, dans l'ordre d'engine_resignation.options. */
static const char *const resign_kind_names[] = { "single", "gammon", "backgammon" };
/* resign : l'abandon du joueur au trait (voir engine_resignation_of). */
static int
run_resign_command(const options *opt)
{
const char *position_id = opt->args[0], *match_id = opt->args[1];
engine_resignation r;
engine_status status;
int i;
if (opt->arg_count != 2)
return usage_error("arguments attendus : POSITION_ID MATCH_ID");
status = engine_resignation_of(position_id, match_id, &r);
if (status != ENGINE_OK)
return print_engine_error(status);
printf("{\"position_id\": \"%s\", \"match_id\": \"%s\", \"probabilities\": ",
position_id, match_id);
print_probabilities(r.probabilities);
printf(", \"equity_before\": " NUMBER ", \"options\": [", r.equity_before);
for (i = 0; i < ENGINE_RESIGN_KINDS; i++) {
const engine_resign_option *o = &r.options[i];
printf("%s{\"kind\": \"%s\", \"possible\": %s, \"points\": %d, "
"\"equity_after\": " NUMBER ", \"accepted\": %s}", i ? ", " : "",
resign_kind_names[i], o->possible ? "true" : "false", o->points, o->equity_after,
o->accepted ? "true" : "false");
}
printf("]}\n");
return EXIT_SUCCESS;
}
/* Dossier « data » à côté du programme. */
static char *
default_data_dir(const char *program)
@@ -886,6 +924,8 @@ main(int argc, char **argv)
result = run_analyse_cube_command(&opt);
else if (strcmp(opt.command, "luck") == 0)
result = run_luck_command(&opt);
else if (strcmp(opt.command, "resign") == 0)
result = run_resign_command(&opt);
else
result = usage_error("commande inconnue : " COMMANDS);