From 1d21ac15d22b41c387d63be8cf99ef18e37f87d2 Mon Sep 17 00:00:00 2001 From: Pierre MARTIN Date: Thu, 12 Nov 2026 02:47:38 +0100 Subject: [PATCH] Moteur : classement de l'analyse d'un coup, comme gnubg de bureau MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit engine_analyse_move rend les dix premiers coups de la liste de l'analyse, chacun au niveau où gnubg l'a évalué, et refait d'abord l'analyse de la chance comme AnalyzeMove : son cache change les coups restés à 0 pli. Les références d'analyse gagnent le niveau de chaque coup du classement, comparé par compare.py. Co-Authored-By: Claude Opus 5.5 --- engine-cli/main.c | 12 +- engine/engine.c | 40 ++++-- engine/include/engine.h | 22 +++- tests/reference/README.md | 10 +- .../analysis/move-bearoff-doubles.json | 2 + .../analysis/move-blitz-doubles.json | 119 ++++++++++++++++++ tests/reference/analysis/move-crawford.json | 20 +++ tests/reference/analysis/move-forced.json | 2 + tests/reference/analysis/move-jacoby.json | 24 ++++ tests/reference/analysis/move-luck-lucky.json | 20 +++ .../analysis/move-luck-unlucky-bearoff.json | 8 ++ .../reference/analysis/move-luck-unlucky.json | 20 +++ tests/reference/analysis/move-match.json | 20 +++ .../analysis/move-middlegame-blunder.json | 24 ++++ .../analysis/move-middlegame-close.json | 20 +++ .../analysis/move-opening-31-best.json | 20 +++ .../analysis/move-opening-31-error.json | 20 +++ .../analysis/move-opening-65-error.json | 14 +++ .../analysis/move-opening-double.json | 20 +++ tests/reference/analysis/move-race.json | 39 ++++++ tests/reference/compare.py | 30 +++++ tests/reference/generate.py | 29 +++-- tests/test_reference.sh | 3 +- 23 files changed, 516 insertions(+), 22 deletions(-) diff --git a/engine-cli/main.c b/engine-cli/main.c index bd05cda..421133e 100644 --- a/engine-cli/main.c +++ b/engine-cli/main.c @@ -43,7 +43,8 @@ * analyse du coup joué (POSITION_JOUÉE : * position après le coup, vue du joueur * qui l'a joué, comme position_id dans - * moves et legal) + * moves et legal), avec le classement + * de l'analyse (dix coups au plus) * analysecube POSITION_ID MATCH_ID DÉCISION * analyse d'une décision de videau : * no_double ou double (joueur au trait), @@ -684,7 +685,7 @@ run_analyse_move_command(const options *opt) const char *played_id = opt->args[3]; engine_move_analysis a; engine_status status; - int die1, die2; + int die1, die2, i; if (opt->arg_count != 4) return usage_error("arguments attendus : POSITION_ID MATCH_ID DÉS POSITION_JOUÉE"); @@ -705,6 +706,13 @@ run_analyse_move_command(const options *opt) printf(", \"best\": "); print_move(&a.best, 1); } + printf(", \"ranking\": ["); + for (i = 0; i < a.ranking_count; i++) { + if (i > 0) + printf(", "); + print_move(&a.ranking[i], 1); + } + printf("]"); printf(", \"equity_loss\": " NUMBER ", \"skill\": \"%s\"}\n", a.equity_loss, skill_names[a.skill]); return EXIT_SUCCESS; diff --git a/engine/engine.c b/engine/engine.c index d038d74..b40be99 100644 --- a/engine/engine.c +++ b/engine/engine.c @@ -512,6 +512,8 @@ engine_level_best_moves(const char *position_id, const char *match_id, int die1, /* ------------------------------------------------- Analyse d'un coup joué */ +static float luck_analysis(const char *position_id, position *pos, int die1, int die2); + engine_status engine_analyse_move(const char *position_id, const char *match_id, int die1, int die2, const char *played_position_id, int ply, engine_move_analysis *analysis) @@ -546,6 +548,17 @@ engine_analyse_move(const char *position_id, const char *match_id, int die1, int * premier. */ memset(analysis, 0, sizeof *analysis); + /* + * gnubg analyse la chance du jet juste avant le coup (AnalyzeMove, + * l. 679-682), à 0 pli sans élagage, et garde ces évaluations dans son + * cache, qui ne distingue pas une évaluation à 0 pli avec ou sans + * réseaux d'élagage : le tri à 0 pli de FindnSaveBestMoves les reprend + * ensuite, ce qui change l'équité des coups restés à 0 pli, et parfois + * ceux que les filtres retiennent. Faire de même, sans garder le + * résultat, donne le classement de gnubg de bureau. + */ + if (luck_analysis(position_id, &pos, die1, die2) == ERR_VAL) + return ENGINE_ERROR_INTERNAL; if (FindnSaveBestMoves(&list, die1, die2, (ConstTanBoard) pos.board, &played_key, TRUE, DOUBTFUL_THRESHOLD, &pos.cube, &context, aaamfMoveFilterSettings[0]) < 0) @@ -565,6 +578,10 @@ engine_analyse_move(const char *position_id, const char *match_id, int die1, int status = ENGINE_OK; break; } + /* Le classement : le début de la même liste, dans l'ordre de gnubg. */ + for (i = 0; i < list.cMoves && i < ENGINE_ANALYSIS_RANKING; i++) + fill_move(&analysis->ranking[i], &list.amMoves[i], &pos, 1); + analysis->ranking_count = (int) i; g_free(list.amMoves); return status; } @@ -1005,13 +1022,25 @@ luck_first(ConstTanBoard board, int i0, int j0, cubeinfo *cube) return equities[i0][j0] - mean / 30.0f; } +/* LuckAnalysis (analysis.c l. 252-268) : dés rangés du plus fort au plus + * faible ; LuckFirst à la position de départ hors doubles. */ +static float +luck_analysis(const char *position_id, position *pos, int die1, int die2) +{ + int high = (die1 > die2 ? die1 : die2) - 1; + int low = (die1 > die2 ? die2 : die1) - 1; + + if (strcmp(position_id, START_POSITION_ID) == 0 && high != low) + return luck_first((ConstTanBoard) pos->board, high, low, &pos->cube); + return luck_normal((ConstTanBoard) pos->board, high, low, &pos->cube); +} + engine_status engine_luck_of(const char *position_id, const char *match_id, int die1, int die2, engine_luck *luck) { position pos; engine_status status; - int high, low; float value; status = decode_position(position_id, match_id, &pos); @@ -1021,14 +1050,7 @@ engine_luck_of(const char *position_id, const char *match_id, int die1, int die2 return status; start_evaluation(); - /* LuckAnalysis (analysis.c l. 252-268) : dés rangés du plus fort au plus - * faible ; LuckFirst à la position de départ hors doubles. */ - high = (die1 > die2 ? die1 : die2) - 1; - low = (die1 > die2 ? die2 : die1) - 1; - if (strcmp(position_id, START_POSITION_ID) == 0 && high != low) - value = luck_first((ConstTanBoard) pos.board, high, low, &pos.cube); - else - value = luck_normal((ConstTanBoard) pos.board, high, low, &pos.cube); + value = luck_analysis(position_id, &pos, die1, die2); if (value == ERR_VAL) return ENGINE_ERROR_INTERNAL; luck->luck = value; diff --git a/engine/include/engine.h b/engine/include/engine.h index 4e99ed4..66197ad 100644 --- a/engine/include/engine.h +++ b/engine/include/engine.h @@ -207,6 +207,10 @@ typedef struct { * (double_take <= double_pass) */ } engine_cube; +/* Coups gardés dans le classement d'une analyse : les dix premiers, comme + * les positions de référence (tests/reference/README.md). */ +#define ENGINE_ANALYSIS_RANKING 10 + /* Analyse d'un coup joué, comme l'analyse de partie de gnubg. */ typedef struct { int move_count; /* nombre de coups légaux (0 : aucun coup @@ -218,6 +222,14 @@ typedef struct { float equity_loss; /* équité du coup joué moins celle du meilleur : * 0 ou négative */ engine_skill skill; /* appréciation de gnubg pour cette perte */ + /* Le classement de l'analyse, du meilleur au moins bon : les premiers + * coups de la liste que gnubg garde pour l'analyse de partie (ce que + * montre son panneau d'analyse), chacun au niveau où gnubg l'a + * évalué. Le meilleur coup et le coup joué y ont les mêmes évaluations + * que best et played ; le coup joué n'y figure que s'il est parmi les + * premiers. */ + engine_move ranking[ENGINE_ANALYSIS_RANKING]; + int ranking_count; } engine_move_analysis; /* Analyse d'une décision de videau, comme l'analyse de partie de gnubg. */ @@ -452,7 +464,15 @@ engine_luck_rating engine_luck_rating_of(float luck); * Analyse le coup joué par le joueur au trait avec le jet die1, die2, au * niveau ply, comme l'analyse de partie de gnubg (AnalyzeMove dans * analysis.c : FindnSaveBestMoves avec le coup joué, seuil « douteux », - * filtre « Normal », sans RefreshMoveList). played_position_id est la + * filtre « Normal », sans RefreshMoveList), classement compris. + * + * Niveaux : gnubg n'évalue au niveau ply que les coups retenus par ses + * filtres ; les autres gardent l'évaluation d'un niveau inférieur (champ + * ply de chaque coup, même convention que gnubg de bureau : 0 = statique). + * Si un seul coup passe le filtre du niveau ply - 1, gnubg s'arrête là, et + * tout le classement reste à ce niveau, sauf quand le coup joué est une + * erreur (écart au meilleur supérieur au seuil « douteux ») : le meilleur + * coup et le coup joué sont alors réévalués au niveau ply. played_position_id est la * position après le coup, vue du joueur qui vient de le jouer (champ * position_id d'engine_move). ENGINE_ERROR_MOVE si ce n'est pas un coup * légal ; si aucun coup n'est possible, move_count vaut 0. diff --git a/tests/reference/README.md b/tests/reference/README.md index 31b7f88..302285a 100644 --- a/tests/reference/README.md +++ b/tests/reference/README.md @@ -256,7 +256,11 @@ Un fichier de résultat reprend le cas, avec `type` (`move`, `cube` ou gnubg plus 1), `played_equity`, `best_move`, `best_equity`, `equity_loss` (perte du coup joué, 0 ou négative : statistique « error-skill » de gnubg changée de signe), `skill` (`none`, `doubtful`, `bad`, `very_bad`) et - `ranking` (les dix premiers coups, et jusqu'au coup joué) ; plus, une fois + `ranking` (les dix premiers coups, et jusqu'au coup joué, chacun avec + `move`, `ply` et `equity` : comme pour `hint`, `ply` est le niveau auquel + gnubg a réellement évalué le coup ; à la différence de `hint`, l'analyse + réévalue au niveau demandé le meilleur coup et le coup joué quand celui-ci + est une erreur, au-delà du seuil « douteux ») ; plus, une fois pour toutes, `luck` : `value` (chance du jet) et `rating` (`very_unlucky`, `unlucky`, `none`, `lucky`, `very_lucky`) ; - **videau** : `analysed` (gnubg analyse-t-il cette décision ? pas à la @@ -337,6 +341,10 @@ Pour chaque analyse (`engine-cli analysemove`, `analysecube`, `luck`, et équité que le coup joué, à la tolérance près : remarque), même meilleur coup sauf égalité, et `played_equity`, `best_equity`, `equity_loss` à la tolérance près ; +- classement de l'analyse (`ranking`, dix coups au plus) : chaque coup de + gnubg présent (sauf égalité avec le dixième), au même `ply` et à la même + équité à la tolérance près ; son premier coup et le coup joué y sont + exactement `best` et `played` ; - chance : `value` à la tolérance près ; - videau : même `analysed`, même décision et équités à la tolérance près, `equity_loss` à la tolérance près ; diff --git a/tests/reference/analysis/move-bearoff-doubles.json b/tests/reference/analysis/move-bearoff-doubles.json index cb72f8f..115bd53 100644 --- a/tests/reference/analysis/move-bearoff-doubles.json +++ b/tests/reference/analysis/move-bearoff-doubles.json @@ -25,6 +25,7 @@ "ranking": [ { "move": "6/off(2) 4/off 1/off", + "ply": 0, "equity": 0.8888838 } ] @@ -42,6 +43,7 @@ "ranking": [ { "move": "6/off(2) 4/off 1/off", + "ply": 0, "equity": 0.8888838 } ] diff --git a/tests/reference/analysis/move-blitz-doubles.json b/tests/reference/analysis/move-blitz-doubles.json index 3360416..0d73843 100644 --- a/tests/reference/analysis/move-blitz-doubles.json +++ b/tests/reference/analysis/move-blitz-doubles.json @@ -25,438 +25,547 @@ "ranking": [ { "move": "13/10 6/3 4/1*(2)", + "ply": 0, "equity": 0.9465638 }, { "move": "8/5 6/3 4/1*(2)", + "ply": 0, "equity": 0.9422797 }, { "move": "13/7 13/10 6/3", + "ply": 0, "equity": 0.94128984 }, { "move": "13/7 8/5 6/3", + "ply": 0, "equity": 0.9370698 }, { "move": "13/10(2) 7/4 6/3", + "ply": 0, "equity": 0.93615985 }, { "move": "13/10(2) 8/5 6/3", + "ply": 0, "equity": 0.9330082 }, { "move": "13/10 8/5 7/4 6/3", + "ply": 0, "equity": 0.932737 }, { "move": "13/10 7/1* 6/3", + "ply": 0, "equity": 0.9313148 }, { "move": "8/5 7/1* 6/3", + "ply": 0, "equity": 0.93129885 }, { "move": "13/4 6/3", + "ply": 0, "equity": 0.92980635 }, { "move": "13/10 8/5(2) 6/3", + "ply": 0, "equity": 0.9264537 }, { "move": "13/10(3) 6/3", + "ply": 0, "equity": 0.9262361 }, { "move": "13/10(2) 4/1*(2)", + "ply": 0, "equity": 0.92529553 }, { "move": "8/5(2) 7/4 6/3", + "ply": 0, "equity": 0.9252107 }, { "move": "7/1* 6/3 4/1", + "ply": 0, "equity": 0.92395884 }, { "move": "13/10 6/3 5/2(2)", + "ply": 0, "equity": 0.9204093 }, { "move": "13/7 4/1*(2)", + "ply": 0, "equity": 0.9190106 }, { "move": "13/7(2)", + "ply": 0, "equity": 0.9184398 }, { "move": "13/10 8/5 4/1*(2)", + "ply": 0, "equity": 0.9182539 }, { "move": "7/4 6/3 5/2(2)", + "ply": 0, "equity": 0.91752934 }, { "move": "13/7 13/10(2)", + "ply": 0, "equity": 0.91483337 }, { "move": "13/10 8/2 6/3", + "ply": 0, "equity": 0.912639 }, { "move": "13/7 13/10 8/5", + "ply": 0, "equity": 0.91152656 }, { "move": "13/10(2) 7/1*", + "ply": 0, "equity": 0.9115156 }, { "move": "13/1*", + "ply": 0, "equity": 0.9111869 }, { "move": "13/10(2) 6/3 4/1*", + "ply": 0, "equity": 0.91055506 }, { "move": "8/2 8/5 6/3", + "ply": 0, "equity": 0.9091699 }, { "move": "8/2 7/4 6/3", + "ply": 0, "equity": 0.90897554 }, { "move": "13/7 8/5(2)", + "ply": 0, "equity": 0.90817225 }, { "move": "13/7 6/3 4/1*", + "ply": 0, "equity": 0.90714073 }, { "move": "13/10(2) 8/5 7/4", + "ply": 0, "equity": 0.9070756 }, { "move": "8/2(2)", + "ply": 0, "equity": 0.9065211 }, { "move": "13/10 8/5 7/1*", + "ply": 0, "equity": 0.90571 }, { "move": "13/10(3) 7/4", + "ply": 0, "equity": 0.9040942 }, { "move": "13/10 8/5 6/3 4/1*", + "ply": 0, "equity": 0.90343916 }, { "move": "8/5(2) 4/1*(2)", + "ply": 0, "equity": 0.90325713 }, { "move": "5/2(2) 4/1*(2)", + "ply": 0, "equity": 0.90183336 }, { "move": "13/10 7/1* 4/1", + "ply": 0, "equity": 0.9013542 }, { "move": "13/4 7/4", + "ply": 0, "equity": 0.9010268 }, { "move": "13/7 5/2(2)", + "ply": 0, "equity": 0.90037674 }, { "move": "8/5(2) 7/1*", + "ply": 0, "equity": 0.89956194 }, { "move": "13/10 8/5(2) 7/4", + "ply": 0, "equity": 0.8988826 }, { "move": "8/2 6/3 5/2", + "ply": 0, "equity": 0.8984738 }, { "move": "13/4 13/10", + "ply": 0, "equity": 0.89749956 }, { "move": "6/3(2) 4/1*(2)", + "ply": 0, "equity": 0.8951012 }, { "move": "13/10(2) 8/5(2)", + "ply": 0, "equity": 0.89493525 }, { "move": "13/7 8/2", + "ply": 0, "equity": 0.8946096 }, { "move": "13/7 6/3(2)", + "ply": 0, "equity": 0.89403474 }, { "move": "7/1* 5/2(2)", + "ply": 0, "equity": 0.8924208 }, { "move": "8/5 7/1* 4/1", + "ply": 0, "equity": 0.891961 }, { "move": "13/10(2) 6/3(2)", + "ply": 0, "equity": 0.89077055 }, { "move": "13/4 8/5", + "ply": 0, "equity": 0.8907301 }, { "move": "8/5(2) 6/3 4/1*", + "ply": 0, "equity": 0.8900244 }, { "move": "13/10(2) 5/2(2)", + "ply": 0, "equity": 0.8890666 }, { "move": "7/4 6/3(3)", + "ply": 0, "equity": 0.8890004 }, { "move": "13/10 7/4 5/2(2)", + "ply": 0, "equity": 0.8888954 }, { "move": "8/2 8/5 7/4", + "ply": 0, "equity": 0.8876569 }, { "move": "13/10(4)", + "ply": 0, "equity": 0.88716996 }, { "move": "7/1* 6/3(2)", + "ply": 0, "equity": 0.8856077 }, { "move": "8/2 4/1*(2)", + "ply": 0, "equity": 0.8853629 }, { "move": "13/10 6/3(3)", + "ply": 0, "equity": 0.8853096 }, { "move": "13/7 6/3 5/2", + "ply": 0, "equity": 0.8831558 }, { "move": "13/10 8/2 7/4", + "ply": 0, "equity": 0.8819176 }, { "move": "7/1* 4/1(2)", + "ply": 0, "equity": 0.88113916 }, { "move": "13/10 7/4 6/3(2)", + "ply": 0, "equity": 0.88064635 }, { "move": "13/10(3) 8/5", + "ply": 0, "equity": 0.88049895 }, { "move": "6/3 5/2(2) 4/1*", + "ply": 0, "equity": 0.8790827 }, { "move": "13/10(2) 8/2", + "ply": 0, "equity": 0.8782023 }, { "move": "6/3 5/2 4/1*(2)", + "ply": 0, "equity": 0.8774586 }, { "move": "8/5 6/3(3)", + "ply": 0, "equity": 0.8774268 }, { "move": "8/2 7/1*", + "ply": 0, "equity": 0.8772669 }, { "move": "13/7 13/10 4/1*", + "ply": 0, "equity": 0.87700987 }, { "move": "13/10 8/5 6/3(2)", + "ply": 0, "equity": 0.8757389 }, { "move": "13/10 8/2 8/5", + "ply": 0, "equity": 0.87530077 }, { "move": "13/10(2) 6/3 5/2", + "ply": 0, "equity": 0.87215745 }, { "move": "13/7 8/5 4/1*", + "ply": 0, "equity": 0.87202764 }, { "move": "8/5 7/4 6/3(2)", + "ply": 0, "equity": 0.86896765 }, { "move": "7/1* 6/3 5/2", + "ply": 0, "equity": 0.8687051 }, { "move": "13/10 7/4 6/3 5/2", + "ply": 0, "equity": 0.8679464 }, { "move": "8/2 6/3 4/1*", + "ply": 0, "equity": 0.86750233 }, { "move": "13/10(2) 8/5 4/1*", + "ply": 0, "equity": 0.86701244 }, { "move": "8/5(2) 6/3(2)", + "ply": 0, "equity": 0.86167765 }, { "move": "13/10(3) 4/1*", + "ply": 0, "equity": 0.8568015 }, { "move": "6/3(2) 5/2(2)", + "ply": 0, "equity": 0.85501754 }, { "move": "8/2 7/4 5/2", + "ply": 0, "equity": 0.8537997 }, { "move": "8/2 5/2(2)", + "ply": 0, "equity": 0.8524791 }, { "move": "13/10 8/5(2) 4/1*", + "ply": 0, "equity": 0.84969926 }, { "move": "13/10 8/2 5/2", + "ply": 0, "equity": 0.8466199 }, { "move": "8/2 6/3(2)", + "ply": 0, "equity": 0.80814815 }, { "move": "13/10 5/2(2) 4/1*", + "ply": 0, "equity": 0.8037353 }, { "move": "13/10 5/2 4/1*(2)", + "ply": 0, "equity": 0.77350885 }, { "move": "13/10 6/3(2) 4/1*", + "ply": 0, "equity": 0.74067366 }, { "move": "13/7 13/10 5/2", + "ply": 0, "equity": 0.72703636 }, { "move": "13/10(2) 7/4 5/2", + "ply": 0, "equity": 0.7053956 }, { "move": "6/3(3) 4/1*", + "ply": 0, "equity": 0.66575944 }, { "move": "13/10 7/1* 5/2", + "ply": 0, "equity": 0.6462204 }, { "move": "8/5 6/3(2) 4/1*", + "ply": 0, "equity": 0.6374039 }, { "move": "8/2 8/5 4/1*", + "ply": 0, "equity": 0.62353325 }, { "move": "13/10 8/2 4/1*", + "ply": 0, "equity": 0.61257124 }, { "move": "13/10 6/3 5/2 4/1*", + "ply": 0, "equity": 0.5349428 }, { "move": "7/1* 5/2 4/1", + "ply": 0, "equity": 0.45721298 }, { "move": "8/2 5/2 4/1*", + "ply": 0, "equity": 0.44362232 }, { "move": "13/4 5/2", + "ply": 0, "equity": 0.43828273 }, { "move": "13/10(3) 5/2", + "ply": 0, "equity": 0.2798175 }, { "move": "13/10 6/3(2) 5/2", + "ply": 0, "equity": 0.24207813 }, { "move": "6/3(3) 5/2", + "ply": 0, "equity": 0.23385207 }, { "move": "7/4 6/3(2) 5/2", + "ply": 0, "equity": 0.22096781 }, { "move": "13/7 5/2 4/1*", + "ply": 0, "equity": 0.18849733 }, { "move": "13/10(2) 5/2 4/1*", + "ply": 0, "equity": 0.084023334 } ] @@ -474,42 +583,52 @@ "ranking": [ { "move": "13/10 7/1* 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/7 13/10 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/10(2) 8/5 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/7 8/5 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/10(2) 7/4 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/10 8/5 7/4 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/10(2) 5/2 4/1*", + "ply": 2, "equity": -0.022027964 }, { "move": "13/10 8/5(2) 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/4 6/3", + "ply": 2, "equity": 1.0 }, { "move": "13/10 6/3 4/1*(2)", + "ply": 2, "equity": 0.99692726 } ] diff --git a/tests/reference/analysis/move-crawford.json b/tests/reference/analysis/move-crawford.json index 90985fc..2ebbe8e 100644 --- a/tests/reference/analysis/move-crawford.json +++ b/tests/reference/analysis/move-crawford.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "8/5 6/2", + "ply": 0, "equity": 0.7345603 }, { "move": "5/2 5/1*", + "ply": 0, "equity": 0.7229391 }, { "move": "8/1*", + "ply": 0, "equity": 0.71705425 }, { "move": "13/10 6/2", + "ply": 0, "equity": 0.7142835 }, { "move": "13/9 8/5", + "ply": 0, "equity": 0.6963019 }, { "move": "8/5 8/4", + "ply": 0, "equity": 0.68610644 }, { "move": "13/10 8/4", + "ply": 0, "equity": 0.6855368 }, { "move": "13/10 13/9", + "ply": 0, "equity": 0.6818689 }, { "move": "13/6", + "ply": 0, "equity": 0.6633271 }, { "move": "13/9 5/2", + "ply": 0, "equity": 0.6538005 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "8/5 6/2", + "ply": 2, "equity": 0.7697691 }, { "move": "13/10 6/2", + "ply": 2, "equity": 0.7615671 }, { "move": "13/9 8/5", + "ply": 2, "equity": 0.69608325 }, { "move": "5/2 5/1*", + "ply": 2, "equity": 0.6911188 }, { "move": "8/1*", + "ply": 2, "equity": 0.6836242 }, { "move": "13/10 13/9", + "ply": 2, "equity": 0.6807338 }, { "move": "13/10 8/4", + "ply": 1, "equity": 0.6733323 }, { "move": "13/6", + "ply": 1, "equity": 0.66055346 }, { "move": "8/5 8/4", + "ply": 1, "equity": 0.6556259 }, { "move": "13/9 5/2", + "ply": 1, "equity": 0.645951 } ] diff --git a/tests/reference/analysis/move-forced.json b/tests/reference/analysis/move-forced.json index 755a2e4..acdd967 100644 --- a/tests/reference/analysis/move-forced.json +++ b/tests/reference/analysis/move-forced.json @@ -25,6 +25,7 @@ "ranking": [ { "move": "bar/24", + "ply": 0, "equity": -1.0 } ] @@ -42,6 +43,7 @@ "ranking": [ { "move": "bar/24", + "ply": 0, "equity": -1.0 } ] diff --git a/tests/reference/analysis/move-jacoby.json b/tests/reference/analysis/move-jacoby.json index 1deab70..2a98cb3 100644 --- a/tests/reference/analysis/move-jacoby.json +++ b/tests/reference/analysis/move-jacoby.json @@ -25,58 +25,72 @@ "ranking": [ { "move": "13/3", + "ply": 0, "equity": 0.9328213 }, { "move": "13/9 13/7", + "ply": 0, "equity": 0.9175232 }, { "move": "8/2 7/3", + "ply": 0, "equity": 0.91263336 }, { "move": "13/7 8/4", + "ply": 0, "equity": 0.90736973 }, { "move": "13/9 7/1*", + "ply": 0, "equity": 0.9053596 }, { "move": "8/2 6/2", + "ply": 0, "equity": 0.9017469 }, { "move": "8/4 7/1*", + "ply": 0, "equity": 0.89993495 }, { "move": "13/7 6/2", + "ply": 0, "equity": 0.8962312 }, { "move": "7/1* 5/1", + "ply": 0, "equity": 0.8907822 }, { "move": "7/1* 6/2", + "ply": 0, "equity": 0.87481093 }, { "move": "13/9 8/2", + "ply": 0, "equity": 0.87251335 }, { "move": "8/4 8/2", + "ply": 0, "equity": 0.8716274 }, { "move": "13/7 5/1*", + "ply": 0, "equity": 0.87005275 }, { "move": "8/2 5/1*", + "ply": 0, "equity": 0.50889754 } ] @@ -94,42 +108,52 @@ "ranking": [ { "move": "13/3", + "ply": 2, "equity": 1.0 }, { "move": "13/9 13/7", + "ply": 2, "equity": 0.99894416 }, { "move": "8/2 7/3", + "ply": 2, "equity": 0.99641544 }, { "move": "13/7 8/4", + "ply": 2, "equity": 0.98718643 }, { "move": "13/7 6/2", + "ply": 2, "equity": 0.9808178 }, { "move": "13/9 7/1*", + "ply": 2, "equity": 0.9452111 }, { "move": "8/2 5/1*", + "ply": 2, "equity": 0.3304975 }, { "move": "8/4 7/1*", + "ply": 1, "equity": 0.93114305 }, { "move": "7/1* 5/1", + "ply": 1, "equity": 0.91711015 }, { "move": "8/2 6/2", + "ply": 1, "equity": 0.9160911 } ] diff --git a/tests/reference/analysis/move-luck-lucky.json b/tests/reference/analysis/move-luck-lucky.json index f98e789..892af6b 100644 --- a/tests/reference/analysis/move-luck-lucky.json +++ b/tests/reference/analysis/move-luck-lucky.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "13/5 11/3", + "ply": 0, "equity": 0.16933289 }, { "move": "13/9(2) 11/3", + "ply": 0, "equity": 0.16701066 }, { "move": "13/5 9/5 7/3", + "ply": 0, "equity": 0.16552198 }, { "move": "13/5(2)", + "ply": 0, "equity": 0.16473158 }, { "move": "13/5 13/9 11/7", + "ply": 0, "equity": 0.16365689 }, { "move": "13/5 13/9 7/3", + "ply": 0, "equity": 0.16245355 }, { "move": "13/5 11/7 9/5", + "ply": 0, "equity": 0.16167049 }, { "move": "11/3 9/5(2)", + "ply": 0, "equity": 0.16043647 }, { "move": "13/9 11/3 11/7", + "ply": 0, "equity": 0.1603657 }, { "move": "13/5 11/7(2)", + "ply": 0, "equity": 0.1602792 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "13/5 11/3", + "ply": 2, "equity": 0.15129912 }, { "move": "13/5 13/9 11/7", + "ply": 2, "equity": 0.15059008 }, { "move": "13/9(2) 11/3", + "ply": 2, "equity": 0.14950007 }, { "move": "13/5 11/7 9/5", + "ply": 2, "equity": 0.14858595 }, { "move": "11/3 11/7 9/5", + "ply": 2, "equity": 0.14829463 }, { "move": "13/9 11/3 11/7", + "ply": 2, "equity": 0.1463402 }, { "move": "13/5 9/5 7/3", + "ply": 1, "equity": 0.13938732 }, { "move": "13/5 11/7(2)", + "ply": 1, "equity": 0.13921705 }, { "move": "13/9(2) 11/7(2)", + "ply": 1, "equity": 0.13873637 }, { "move": "13/5 13/9 6/2", + "ply": 1, "equity": 0.13852078 } ] diff --git a/tests/reference/analysis/move-luck-unlucky-bearoff.json b/tests/reference/analysis/move-luck-unlucky-bearoff.json index a96a1ff..2d15e71 100644 --- a/tests/reference/analysis/move-luck-unlucky-bearoff.json +++ b/tests/reference/analysis/move-luck-unlucky-bearoff.json @@ -25,18 +25,22 @@ "ranking": [ { "move": "3/off", + "ply": 0, "equity": -0.8607614 }, { "move": "2/off 1/off", + "ply": 0, "equity": -0.8607614 }, { "move": "2/1 2/off", + "ply": 0, "equity": -0.95561147 }, { "move": "3/1 2/1", + "ply": 0, "equity": -1.0 } ] @@ -54,18 +58,22 @@ "ranking": [ { "move": "3/off", + "ply": 2, "equity": -0.8607614 }, { "move": "2/off 1/off", + "ply": 2, "equity": -0.8607614 }, { "move": "2/1 2/off", + "ply": 2, "equity": -0.95561147 }, { "move": "3/1 2/1", + "ply": 1, "equity": -1.0 } ] diff --git a/tests/reference/analysis/move-luck-unlucky.json b/tests/reference/analysis/move-luck-unlucky.json index 16cb6c9..9298b95 100644 --- a/tests/reference/analysis/move-luck-unlucky.json +++ b/tests/reference/analysis/move-luck-unlucky.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "18/9", + "ply": 0, "equity": 0.2544027 }, { "move": "18/14 13/8", + "ply": 0, "equity": 0.22496489 }, { "move": "24/20 18/13", + "ply": 0, "equity": 0.20747662 }, { "move": "24/20 13/8", + "ply": 0, "equity": 0.1158272 }, { "move": "13/9 13/8", + "ply": 0, "equity": 0.09201278 }, { "move": "24/15", + "ply": 0, "equity": 0.061017293 }, { "move": "18/13 6/2", + "ply": 0, "equity": 0.03581623 }, { "move": "13/4", + "ply": 0, "equity": -0.028887823 }, { "move": "13/8 6/2", + "ply": 0, "equity": -0.033572298 }, { "move": "18/13 8/4", + "ply": 0, "equity": -0.09662818 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "18/9", + "ply": 2, "equity": 0.27687487 }, { "move": "18/14 13/8", + "ply": 2, "equity": 0.21801135 }, { "move": "24/20 18/13", + "ply": 2, "equity": 0.21000355 }, { "move": "24/20 13/8", + "ply": 2, "equity": 0.1144446 }, { "move": "13/9 13/8", + "ply": 2, "equity": 0.09412725 }, { "move": "24/15", + "ply": 2, "equity": 0.07892294 }, { "move": "18/13 6/2", + "ply": 1, "equity": -0.020656409 }, { "move": "13/4", + "ply": 0, "equity": -0.028887823 }, { "move": "13/8 6/2", + "ply": 0, "equity": -0.033572298 }, { "move": "18/13 8/4", + "ply": 0, "equity": -0.09662818 } ] diff --git a/tests/reference/analysis/move-match.json b/tests/reference/analysis/move-match.json index 6eb7a82..dc63991 100644 --- a/tests/reference/analysis/move-match.json +++ b/tests/reference/analysis/move-match.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "13/5", + "ply": 0, "equity": 0.7553502 }, { "move": "18/13 8/5", + "ply": 0, "equity": 0.5814649 }, { "move": "24/16*", + "ply": 0, "equity": 0.4581785 }, { "move": "18/10", + "ply": 0, "equity": 0.31719947 }, { "move": "8/5 8/3", + "ply": 0, "equity": 0.31371918 }, { "move": "18/15 13/8", + "ply": 0, "equity": 0.26037523 }, { "move": "24/21 18/13", + "ply": 0, "equity": 0.23547156 }, { "move": "8/3 6/3", + "ply": 0, "equity": 0.15432969 }, { "move": "13/10 13/8", + "ply": 0, "equity": 0.13837479 }, { "move": "18/13 5/2", + "ply": 0, "equity": 0.12815686 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "13/5", + "ply": 2, "equity": 0.85497326 }, { "move": "24/16*", + "ply": 2, "equity": 0.46805125 }, { "move": "18/13 8/5", + "ply": 1, "equity": 0.6511238 }, { "move": "18/10", + "ply": 0, "equity": 0.31719947 }, { "move": "8/5 8/3", + "ply": 0, "equity": 0.31371918 }, { "move": "18/15 13/8", + "ply": 0, "equity": 0.26037523 }, { "move": "24/21 18/13", + "ply": 0, "equity": 0.23547156 }, { "move": "8/3 6/3", + "ply": 0, "equity": 0.15432969 }, { "move": "13/10 13/8", + "ply": 0, "equity": 0.13837479 }, { "move": "18/13 5/2", + "ply": 0, "equity": 0.12815686 } ] diff --git a/tests/reference/analysis/move-middlegame-blunder.json b/tests/reference/analysis/move-middlegame-blunder.json index e581af8..3861a4d 100644 --- a/tests/reference/analysis/move-middlegame-blunder.json +++ b/tests/reference/analysis/move-middlegame-blunder.json @@ -25,58 +25,72 @@ "ranking": [ { "move": "24/14", + "ply": 0, "equity": 0.15439394 }, { "move": "8/2 6/2", + "ply": 0, "equity": 0.10821653 }, { "move": "24/18 13/9", + "ply": 0, "equity": 0.10337136 }, { "move": "24/20 24/18", + "ply": 0, "equity": 0.072762795 }, { "move": "13/9 13/7", + "ply": 0, "equity": 0.0029048775 }, { "move": "24/20 13/7", + "ply": 0, "equity": 9.1438415e-05 }, { "move": "13/3", + "ply": 0, "equity": -0.012697897 }, { "move": "24/18 6/2", + "ply": 0, "equity": -0.075399 }, { "move": "24/18 8/4", + "ply": 0, "equity": -0.088734664 }, { "move": "24/20 8/2", + "ply": 0, "equity": -0.095189385 }, { "move": "13/9 8/2", + "ply": 0, "equity": -0.09528468 }, { "move": "13/7 8/4", + "ply": 0, "equity": -0.12819159 }, { "move": "13/7 6/2", + "ply": 0, "equity": -0.14467186 }, { "move": "8/4 8/2", + "ply": 0, "equity": -0.35321844 } ] @@ -94,42 +108,52 @@ "ranking": [ { "move": "24/14", + "ply": 2, "equity": 0.13111727 }, { "move": "8/2 6/2", + "ply": 2, "equity": 0.11303549 }, { "move": "24/18 13/9", + "ply": 2, "equity": 0.105096616 }, { "move": "24/20 24/18", + "ply": 2, "equity": 0.049068402 }, { "move": "13/3", + "ply": 2, "equity": -0.0040049786 }, { "move": "8/4 8/2", + "ply": 2, "equity": -0.36824828 }, { "move": "13/9 13/7", + "ply": 2, "equity": -0.014309813 }, { "move": "24/20 13/7", + "ply": 1, "equity": -0.029367238 }, { "move": "24/18 8/4", + "ply": 1, "equity": -0.081171095 }, { "move": "24/18 6/2", + "ply": 1, "equity": -0.09313507 } ] diff --git a/tests/reference/analysis/move-middlegame-close.json b/tests/reference/analysis/move-middlegame-close.json index 59487b5..1ef6e82 100644 --- a/tests/reference/analysis/move-middlegame-close.json +++ b/tests/reference/analysis/move-middlegame-close.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "24/14", + "ply": 0, "equity": 0.15439394 }, { "move": "8/2 6/2", + "ply": 0, "equity": 0.10821653 }, { "move": "24/18 13/9", + "ply": 0, "equity": 0.10337136 }, { "move": "24/20 24/18", + "ply": 0, "equity": 0.072762795 }, { "move": "13/9 13/7", + "ply": 0, "equity": 0.0029048775 }, { "move": "24/20 13/7", + "ply": 0, "equity": 9.1438415e-05 }, { "move": "13/3", + "ply": 0, "equity": -0.012697897 }, { "move": "24/18 6/2", + "ply": 0, "equity": -0.075399 }, { "move": "24/18 8/4", + "ply": 0, "equity": -0.088734664 }, { "move": "24/20 8/2", + "ply": 0, "equity": -0.095189385 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "24/14", + "ply": 2, "equity": 0.13111727 }, { "move": "8/2 6/2", + "ply": 2, "equity": 0.11303549 }, { "move": "24/18 13/9", + "ply": 2, "equity": 0.105096616 }, { "move": "24/20 24/18", + "ply": 2, "equity": 0.049068402 }, { "move": "13/3", + "ply": 2, "equity": -0.0040049786 }, { "move": "13/9 13/7", + "ply": 2, "equity": -0.014309813 }, { "move": "24/20 13/7", + "ply": 1, "equity": -0.029367238 }, { "move": "24/18 8/4", + "ply": 1, "equity": -0.081171095 }, { "move": "24/18 6/2", + "ply": 1, "equity": -0.09313507 }, { "move": "24/20 8/2", + "ply": 0, "equity": -0.095189385 } ] diff --git a/tests/reference/analysis/move-opening-31-best.json b/tests/reference/analysis/move-opening-31-best.json index 50dbcd5..ba22887 100644 --- a/tests/reference/analysis/move-opening-31-best.json +++ b/tests/reference/analysis/move-opening-31-best.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "8/5 6/5", + "ply": 0, "equity": 0.21258597 }, { "move": "24/23 13/10", + "ply": 0, "equity": -0.010789523 }, { "move": "24/20", + "ply": 0, "equity": -0.017392516 }, { "move": "24/23 24/21", + "ply": 0, "equity": -0.023609947 }, { "move": "13/9", + "ply": 0, "equity": -0.027675275 }, { "move": "24/21 6/5", + "ply": 0, "equity": -0.04369401 }, { "move": "13/10 6/5", + "ply": 0, "equity": -0.04984435 }, { "move": "24/23 8/5", + "ply": 0, "equity": -0.104100645 }, { "move": "24/23 6/3", + "ply": 0, "equity": -0.10542354 }, { "move": "24/21 8/7", + "ply": 0, "equity": -0.107585564 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "8/5 6/5", + "ply": 1, "equity": 0.20373425 }, { "move": "24/23 13/10", + "ply": 1, "equity": -0.022293653 }, { "move": "24/20", + "ply": 1, "equity": -0.031027086 }, { "move": "24/23 24/21", + "ply": 1, "equity": -0.03213631 }, { "move": "13/9", + "ply": 1, "equity": -0.040205758 }, { "move": "24/21 6/5", + "ply": 0, "equity": -0.04369401 }, { "move": "13/10 6/5", + "ply": 0, "equity": -0.04984435 }, { "move": "24/23 8/5", + "ply": 0, "equity": -0.104100645 }, { "move": "24/23 6/3", + "ply": 0, "equity": -0.10542354 }, { "move": "24/21 8/7", + "ply": 0, "equity": -0.107585564 } ] diff --git a/tests/reference/analysis/move-opening-31-error.json b/tests/reference/analysis/move-opening-31-error.json index 0ac69a9..7ac6e98 100644 --- a/tests/reference/analysis/move-opening-31-error.json +++ b/tests/reference/analysis/move-opening-31-error.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "8/5 6/5", + "ply": 0, "equity": 0.21258597 }, { "move": "24/23 13/10", + "ply": 0, "equity": -0.010789523 }, { "move": "24/20", + "ply": 0, "equity": -0.017392516 }, { "move": "24/23 24/21", + "ply": 0, "equity": -0.023609947 }, { "move": "13/9", + "ply": 0, "equity": -0.027675275 }, { "move": "24/21 6/5", + "ply": 0, "equity": -0.04369401 }, { "move": "13/10 6/5", + "ply": 0, "equity": -0.04984435 }, { "move": "24/23 8/5", + "ply": 0, "equity": -0.104100645 }, { "move": "24/23 6/3", + "ply": 0, "equity": -0.10542354 }, { "move": "24/21 8/7", + "ply": 0, "equity": -0.107585564 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "8/5 6/5", + "ply": 2, "equity": 0.1998143 }, { "move": "24/23 13/10", + "ply": 2, "equity": -0.0118339015 }, { "move": "24/20", + "ply": 1, "equity": -0.031027086 }, { "move": "24/23 24/21", + "ply": 1, "equity": -0.03213631 }, { "move": "13/9", + "ply": 1, "equity": -0.040205758 }, { "move": "24/21 6/5", + "ply": 0, "equity": -0.04369401 }, { "move": "13/10 6/5", + "ply": 0, "equity": -0.04984435 }, { "move": "24/23 8/5", + "ply": 0, "equity": -0.104100645 }, { "move": "24/23 6/3", + "ply": 0, "equity": -0.10542354 }, { "move": "24/21 8/7", + "ply": 0, "equity": -0.107585564 } ] diff --git a/tests/reference/analysis/move-opening-65-error.json b/tests/reference/analysis/move-opening-65-error.json index 0fbce8c..b7fdd2e 100644 --- a/tests/reference/analysis/move-opening-65-error.json +++ b/tests/reference/analysis/move-opening-65-error.json @@ -25,30 +25,37 @@ "ranking": [ { "move": "24/13", + "ply": 0, "equity": 0.082985915 }, { "move": "24/18 13/8", + "ply": 0, "equity": 0.03631018 }, { "move": "13/8 13/7", + "ply": 0, "equity": -0.05142035 }, { "move": "13/2", + "ply": 0, "equity": -0.13522762 }, { "move": "24/18 8/3", + "ply": 0, "equity": -0.14635906 }, { "move": "13/7 8/3", + "ply": 0, "equity": -0.17384717 }, { "move": "8/3 8/2", + "ply": 0, "equity": -0.37779096 } ] @@ -66,30 +73,37 @@ "ranking": [ { "move": "24/13", + "ply": 2, "equity": 0.07996891 }, { "move": "24/18 13/8", + "ply": 2, "equity": 0.03882884 }, { "move": "13/8 13/7", + "ply": 2, "equity": -0.061850794 }, { "move": "13/2", + "ply": 1, "equity": -0.12083713 }, { "move": "24/18 8/3", + "ply": 1, "equity": -0.13999933 }, { "move": "13/7 8/3", + "ply": 0, "equity": -0.17384717 }, { "move": "8/3 8/2", + "ply": 0, "equity": -0.37779096 } ] diff --git a/tests/reference/analysis/move-opening-double.json b/tests/reference/analysis/move-opening-double.json index 5ab51f1..c0b255e 100644 --- a/tests/reference/analysis/move-opening-double.json +++ b/tests/reference/analysis/move-opening-double.json @@ -25,42 +25,52 @@ "ranking": [ { "move": "24/18(2) 13/7(2)", + "ply": 0, "equity": 0.539388 }, { "move": "24/18 13/7(3)", + "ply": 0, "equity": 0.33099693 }, { "move": "24/18(2) 8/2(2)", + "ply": 0, "equity": 0.27119082 }, { "move": "13/7(2) 8/2(2)", + "ply": 0, "equity": 0.1563462 }, { "move": "24/18 13/7(2) 8/2", + "ply": 0, "equity": 0.14750561 }, { "move": "13/7(4)", + "ply": 0, "equity": 0.14310652 }, { "move": "24/18(2) 13/7 8/2", + "ply": 0, "equity": 0.12353878 }, { "move": "13/7(3) 8/2", + "ply": 0, "equity": 0.101389736 }, { "move": "24/18 13/7 8/2(2)", + "ply": 0, "equity": -0.05435923 }, { "move": "24/18 8/2(3)", + "ply": 0, "equity": -0.12482335 } ] @@ -78,42 +88,52 @@ "ranking": [ { "move": "24/18(2) 13/7(2)", + "ply": 1, "equity": 0.5886327 }, { "move": "24/18 13/7(3)", + "ply": 1, "equity": 0.33312234 }, { "move": "24/18(2) 8/2(2)", + "ply": 0, "equity": 0.27119082 }, { "move": "13/7(2) 8/2(2)", + "ply": 0, "equity": 0.1563462 }, { "move": "24/18 13/7(2) 8/2", + "ply": 0, "equity": 0.14750561 }, { "move": "13/7(4)", + "ply": 0, "equity": 0.14310652 }, { "move": "24/18(2) 13/7 8/2", + "ply": 0, "equity": 0.12353878 }, { "move": "13/7(3) 8/2", + "ply": 0, "equity": 0.101389736 }, { "move": "24/18 13/7 8/2(2)", + "ply": 0, "equity": -0.05435923 }, { "move": "24/18 8/2(3)", + "ply": 0, "equity": -0.12482335 } ] diff --git a/tests/reference/analysis/move-race.json b/tests/reference/analysis/move-race.json index 09dea1e..bd3b039 100644 --- a/tests/reference/analysis/move-race.json +++ b/tests/reference/analysis/move-race.json @@ -25,118 +25,147 @@ "ranking": [ { "move": "13/9 11/6", + "ply": 0, "equity": -0.22230339 }, { "move": "11/6 9/5", + "ply": 0, "equity": -0.22993731 }, { "move": "13/8 9/5", + "ply": 0, "equity": -0.23005769 }, { "move": "13/9 13/8", + "ply": 0, "equity": -0.23073325 }, { "move": "13/8 11/7", + "ply": 0, "equity": -0.23153114 }, { "move": "11/7 11/6", + "ply": 0, "equity": -0.2335976 }, { "move": "13/8 7/3", + "ply": 0, "equity": -0.23374501 }, { "move": "11/6 7/3", + "ply": 0, "equity": -0.23394687 }, { "move": "13/4", + "ply": 0, "equity": -0.23507257 }, { "move": "13/9 7/2", + "ply": 0, "equity": -0.23529215 }, { "move": "7/3 7/2", + "ply": 0, "equity": -0.23544219 }, { "move": "11/2", + "ply": 0, "equity": -0.235758 }, { "move": "11/7 9/4", + "ply": 0, "equity": -0.23589191 }, { "move": "13/8 6/2", + "ply": 0, "equity": -0.24026787 }, { "move": "9/5 7/2", + "ply": 0, "equity": -0.24087214 }, { "move": "13/8 5/1", + "ply": 0, "equity": -0.24252185 }, { "move": "9/5 9/4", + "ply": 0, "equity": -0.2440444 }, { "move": "9/4 6/2", + "ply": 0, "equity": -0.24487257 }, { "move": "9/4 7/3", + "ply": 0, "equity": -0.24512678 }, { "move": "11/6 5/1", + "ply": 0, "equity": -0.25016445 }, { "move": "9/4 5/1", + "ply": 0, "equity": -0.25572774 }, { "move": "7/2 5/1", + "ply": 0, "equity": -0.258138 }, { "move": "7/3 6/1", + "ply": 0, "equity": -0.25878713 }, { "move": "7/2 6/2", + "ply": 0, "equity": -0.26088732 }, { "move": "13/9 6/1", + "ply": 0, "equity": -0.26104733 }, { "move": "9/5 6/1", + "ply": 0, "equity": -0.26680842 }, { "move": "11/7 6/1", + "ply": 0, "equity": -0.2670043 }, { "move": "6/2 6/1", + "ply": 0, "equity": -0.27360544 }, { "move": "6/1 5/1", + "ply": 0, "equity": -0.31466243 } ] @@ -154,42 +183,52 @@ "ranking": [ { "move": "13/9 11/6", + "ply": 2, "equity": -0.21922025 }, { "move": "13/9 13/8", + "ply": 2, "equity": -0.2202243 }, { "move": "11/6 9/5", + "ply": 2, "equity": -0.22022447 }, { "move": "13/8 9/5", + "ply": 2, "equity": -0.22088149 }, { "move": "11/7 11/6", + "ply": 2, "equity": -0.22277355 }, { "move": "13/4", + "ply": 2, "equity": -0.2230124 }, { "move": "6/1 5/1", + "ply": 2, "equity": -0.29347342 }, { "move": "11/7 9/4", + "ply": 1, "equity": -0.22985312 }, { "move": "13/8 11/7", + "ply": 1, "equity": -0.23169218 }, { "move": "13/9 7/2", + "ply": 1, "equity": -0.23561361 } ] diff --git a/tests/reference/compare.py b/tests/reference/compare.py index 677da81..8bdd272 100644 --- a/tests/reference/compare.py +++ b/tests/reference/compare.py @@ -210,6 +210,36 @@ def compare_move_analysis(report, cli, case): report.number(where, "equity_loss", expected["equity_loss"], actual["equity_loss"]) same_label(report, where, "skill", expected["skill"], actual["skill"], expected["equity_loss"], SKILL_THRESHOLDS) + compare_analysis_ranking(report, where, expected, actual) + + +def compare_analysis_ranking(report, where, expected, actual): + """Classement de l'analyse : les dix premiers coups de gnubg (le moteur + n'en rend pas plus), au même niveau et à la même équité, à la tolérance + près ; le meilleur coup et le coup joué y ont exactement les évaluations + de best et played.""" + engine = actual["ranking"] + reference = expected["ranking"][:10] + report.same(where, "taille du classement", len(reference), len(engine)) + by_move = {m["move"]: m for m in engine} + for m in reference: + other = by_move.get(m["move"]) + here = "%s classement %s" % (where, m["move"]) + if other is None: + # Un coup à égalité avec le dixième peut changer de côté. + tied = abs(m["equity"] - reference[-1]["equity"]) <= report.tolerance + if not tied: + report.same(here, "présent", True, False) + continue + report.same(here, "ply", m["ply"], other["ply"]) + report.number(here, "equity", m["equity"], other["equity"]) + if engine: + report.same(where, "classement, meilleur coup", actual["best"], engine[0]) + for m in engine: + if m["move"] == actual["played"]["move"]: + report.same(where, "classement, coup joué", actual["played"], m) + report.same(where, "classement, rang du coup joué", actual["rank"], + engine.index(m) + 1) def compare_cube_analysis(report, cli, case): diff --git a/tests/reference/generate.py b/tests/reference/generate.py index 858abaf..2a6b9b6 100644 --- a/tests/reference/generate.py +++ b/tests/reference/generate.py @@ -221,15 +221,25 @@ def set_analysis(ply): def analyse_game(): - """Analyse la partie en cours ; renvoie ses enregistrements et ses - statistiques par joueur (« X », « O »). Le cache est vidé avant : les + """Analyse la partie en cours ; renvoie ses enregistrements, ses + statistiques par joueur (« X », « O ») et les informations du match. Le cache est vidé avant : les évaluations à 2 plis faites pour choisir un coup y laissent des résultats à 0 pli des réseaux d'élagage, que l'analyse à 0 pli reprendrait (voir analyse_move).""" gnubg.command("clear cache") gnubg.command("analyse game") - game = gnubg.match(analysis=1, verbose=1, statistics=1, boards=1)["games"][-1] - return game["game"], game["stats"] + match = gnubg.match(analysis=1, verbose=1, statistics=1, boards=1) + game = match["games"][-1] + return game["game"], game["stats"], match["match-info"] + + +def move_plies(match_info, move): + """Niveau auquel gnubg a évalué un coup de l'analyse : gnubg.match ne + donne le réglage d'un coup (« evalcontext ») que s'il diffère du réglage + par défaut de la partie (« default-eval-context », celui du premier coup + évalué rencontré).""" + context = move.get("evalcontext", {}) + return context.get("plies", match_info["default-eval-context"]["plies"]) def last_record(records, action): @@ -280,7 +290,7 @@ def analyse_move(case, ply): # vient de jouer est la position retournée. played_id = gnubg.positionid(swapped(gnubg.board())) set_analysis(ply) - records, stats = analyse_game() + records, stats, match_info = analyse_game() record = last_record(records, "move") analysis = record["analysis"] moves, index = analysis["moves"], analysis["imove"] @@ -304,7 +314,10 @@ def analyse_move(case, ply): # comptée en positif. "equity_loss": f32(-stats[record["player"]]["moves"]["error-skill"]), "skill": SKILLS[analysis.get("skill")], - "ranking": [{"move": notation(m["move"]), "equity": f32(m["score"])} for m in kept], + # Avec le niveau de chaque coup : les coups écartés par les filtres + # gardent celui d'un niveau inférieur (voir README.md). + "ranking": [{"move": notation(m["move"]), "ply": move_plies(match_info, m), + "equity": f32(m["score"])} for m in kept], } luck = {"value": f32(analysis["luck-value"]), "rating": LUCKS[analysis.get("luck")]} return level, luck @@ -322,7 +335,7 @@ def analyse_cube(case, ply): # meilleur coup, l'analyse du videau portant sur la position avant. gnubg.command("set dice 2 1") gnubg.command("move " + best_move()) - records, stats = analyse_game() + records, stats, _ = analyse_game() record = last_record(records, "move") analysed = "nd-cubeful-eq" in record["analysis"] skill = record["analysis"].get("cube-skill") @@ -332,7 +345,7 @@ def analyse_cube(case, ply): # du double. gnubg.command("double") gnubg.command("drop" if action == "pass" else "take") - records, stats = analyse_game() + records, stats, _ = analyse_game() analysed = "nd-cubeful-eq" in last_record(records, "double").get("analysis", {}) record = last_record(records, {"double": "double", "take": "take", "pass": "drop"}[action]) skill = record.get("analysis", {}).get("skill") diff --git a/tests/test_reference.sh b/tests/test_reference.sh index 12bb5db..ca49b0c 100644 --- a/tests/test_reference.sh +++ b/tests/test_reference.sh @@ -130,7 +130,8 @@ if .type == "move" then and (.played_position_id | test("^[A-Za-z0-9+/]{14}$")) and (.played_equity | nombre) and (.best_move | type) == "string" and (.best_equity | nombre) and (.equity_loss | nombre) and .equity_loss <= 0 and (.skill | skill) - and (.ranking | length) >= ([.rank, ([.move_count, 10] | min)] | max)) + and (.ranking | length) >= ([.rank, ([.move_count, 10] | min)] | max) + and all(.ranking[]; (.move | type) == "string" and (.ply | nombre) and (.equity | nombre))) then empty else "analyse de coup incomplète" end) elif .type == "cube" then (if (.plies | keys) == ["0", "2"] and (.action | IN("no_double", "double", "take", "pass"))