Put that PGN into the MRI

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Put that PGN into the MRI

Post by Rebel »

About creating your own PGN format: :roll:
Dann Corbit wrote: Fri Feb 14, 2020 5:13 pm Further complications:
All the data systems are different.
TCEC is different, and basically every other engine conte.
Furthermore, sometimes the data is from white's perspective and sometimes for the side to move as far as scores go.
And there are dozens of different ways to indicate a book move
About the red, here is compilation what I have seen through the years and how to recognize a book move:

Code: Select all

0s
1s
2s
book
Buch
+0.00/1
+0.00/0
+355.34     // Rybka
0.00/99
With MRI I use a different formula but when changing a supported PGN format it may cause trouble as in your case.

Restoring the PGN to Cutechess format gives the right book move figures.

Your format:

Code: Select all

47. h6 {+M19/33 0.44s} Kb3 {-M20/28 0.21s}
{White wins by adjudication}
1-0
Back to Cutechess

Code: Select all

47. h6 {+M19/33 0.44s} Kb3 {-M20/28 0.21s, White wins by adjudication} 1-0
Anyway, in the upcoming update (tonight I hope) your PGN format will work as well :wink:
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Put that PGN into the MRI

Post by Rebel »

I fixed the open issues / wishes, your (one game) modified PGN gives:

Code: Select all

Phase               Won Games (numbers)           Late Endgame             Match
Overview            MIDG END1 END2 END3      QUEEN ROOK LIGHT PAWN         Score
Stockfish_11-64        0    0    0    1          0    0     0    1   1.0 / 1 (100.0%)
Stockfish_11x2-64      0    0    0    0          0    0     0    0   0.0 / 1 (0.0%)

Phase                   Won games %               Late Endgame             Match
Overview            MIDG END1 END2 END3      QUEEN ROOK LIGHT PAWN         Score
Stockfish_11-64      0.0  0.0  0.0 100%        0.0  0.0   0.0 100%   1.0 / 1 (100.0%)
Stockfish_11x2-64    0.0  0.0  0.0  0.0        0.0  0.0   0.0  0.0   0.0 / 1 (0.0%)

Depths              MIDG END1 END2 END3     BOOK             TIME
Stockfish_11-64     16.3 19.0 17.7 25.1     3.0 (moves)      0:20
Stockfish_11x2-64   14.8 17.0 15.9 21.3     3.0 (moves)      0:09

Suspect opening lines overview (1.00)  
Bad opening line for Stockfish_11x2-64 in game 1, start score -1.07, game lost.  
rnbqkb1r/ppp1p1pp/3p1n2/5P2/3P4/2N5/PPP2PPP/R1BQKBNR b KQkq - sm Bxf5; acd 16; ce -1.07; acs 0.9s; 
1. Book moves (3.0) correct.
2. Length names flexible, press F4 to change the length.
3. Opening is reported as suspect.

On detecting suspect book moves I made a firm choice, first move < margin and game lost -> suspect.

In the game in question black recovers from the -1.07 and thus the opening is not suspect, secondly people play matches with opening books and engines may fall back into the book again with a score of 0.00 and things get complicated.

I think a programmer / book editor just want to know his book or opening set contains bad scores.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Put that PGN into the MRI

Post by Guenther »

Rebel wrote: Wed Feb 19, 2020 5:23 pm About creating your own PGN format: :roll:
Dann Corbit wrote: Fri Feb 14, 2020 5:13 pm Further complications:
All the data systems are different.
TCEC is different, and basically every other engine conte.
Furthermore, sometimes the data is from white's perspective and sometimes for the side to move as far as scores go.
And there are dozens of different ways to indicate a book move
About the red, here is compilation what I have seen through the years and how to recognize a book move:

Code: Select all

0s
1s
2s
book
Buch
+0.00/1
+0.00/0
+355.34     // Rybka
0.00/99
With MRI I use a different formula but when changing a supported PGN format it may cause trouble as in your case.

Restoring the PGN to Cutechess format gives the right book move figures.

Your format:

Code: Select all

47. h6 {+M19/33 0.44s} Kb3 {-M20/28 0.21s}
{White wins by adjudication}
1-0
Back to Cutechess

Code: Select all

47. h6 {+M19/33 0.44s} Kb3 {-M20/28 0.21s, White wins by adjudication} 1-0
Anyway, in the upcoming update (tonight I hope) your PGN format will work as well :wink:
Thanks, I am sorry I forgot about the line with the final termination comment, because I didn't know it was relevant for your book moves parsing.

My afterwards used script (not the different compilation of cutechess), not only removes the unnecessary 's' (some tools I use don't like that for parsing!), but also separates the last move comment from the termination comment, because I find that concatenation ugly.

BTW the XB/WB source contains code for recognizing book moves up to 2006 IIRC, because I once persuaded Alessandro Scotti to add a pgn tag, which saves the bookout eval in the header. The tag looks like this

Code: Select all

[Annotator "2. +0.33   5... +0.04"]
, I think we 'abused' a seldomly used existing tag.

from backend.c

Code: Select all

static int
FindFirstMoveOutOfBook (int side)
{
    int result = -1;

    if( backwardMostMove == 0 && ! startedFromSetupPosition) {
        int index = backwardMostMove;
        int has_book_hit = 0;

        if( (index % 2) != side ) {
            index++;
        }

        while( index < forwardMostMove ) {
            /* Check to see if engine is in book */
            int depth = pvInfoList[index].depth;
            int score = pvInfoList[index].score;
            int in_book = 0;

            if( depth <= 2 ) {
                in_book = 1;
            }
            else if( score == 0 && depth == 63 ) {
                in_book = 1; /* Zappa */
            }
            else if( score == 2 && depth == 99 ) {
                in_book = 1; /* Abrok */
            }

            has_book_hit += in_book;

            if( ! in_book ) {
                result = index;

                break;
            }

            index += 2;
        }
    }

    return result;
}
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Put that PGN into the MRI

Post by Guenther »

Rebel wrote: Wed Feb 19, 2020 5:45 pm I fixed the open issues / wishes, your (one game) modified PGN gives:

Code: Select all

Phase               Won Games (numbers)           Late Endgame             Match
Overview            MIDG END1 END2 END3      QUEEN ROOK LIGHT PAWN         Score
Stockfish_11-64        0    0    0    1          0    0     0    1   1.0 / 1 (100.0%)
Stockfish_11x2-64      0    0    0    0          0    0     0    0   0.0 / 1 (0.0%)

Phase                   Won games %               Late Endgame             Match
Overview            MIDG END1 END2 END3      QUEEN ROOK LIGHT PAWN         Score
Stockfish_11-64      0.0  0.0  0.0 100%        0.0  0.0   0.0 100%   1.0 / 1 (100.0%)
Stockfish_11x2-64    0.0  0.0  0.0  0.0        0.0  0.0   0.0  0.0   0.0 / 1 (0.0%)

Depths              MIDG END1 END2 END3     BOOK             TIME
Stockfish_11-64     16.3 19.0 17.7 25.1     3.0 (moves)      0:20
Stockfish_11x2-64   14.8 17.0 15.9 21.3     3.0 (moves)      0:09

Suspect opening lines overview (1.00)  
Bad opening line for Stockfish_11x2-64 in game 1, start score -1.07, game lost.  
rnbqkb1r/ppp1p1pp/3p1n2/5P2/3P4/2N5/PPP2PPP/R1BQKBNR b KQkq - sm Bxf5; acd 16; ce -1.07; acs 0.9s; 
1. Book moves (3.0) correct.
2. Length names flexible, press F4 to change the length.
3. Opening is reported as suspect.

On detecting suspect book moves I made a firm choice, first move < margin and game lost -> suspect.

In the game in question black recovers from the -1.07 and thus the opening is not suspect, secondly people play matches with opening books and engines may fall back into the book again with a score of 0.00 and things get complicated.

I think a programmer / book editor just want to know his book or opening set contains bad scores.
Thanks, all well, except the time sum, may be a rounding error? It still would be nice to have here also 1 or 2 digit precision.
Note that a lot of people do ultrafast tests and this tool can also check irregularities in game files of other people.

The diff here is already >10% from real numbers. Below is a calculation of the same game (rounded to 2 digits in time sum).

Code: Select all

W: 0:22,76
B: 0:11,47

Code: Select all

#       Wm      WEval           T       TSum    Bm      Beval           T       TSum
4       exf5    +1.36/17        1.920   1.92    Bxf5    -1.07/16        0.920   0.92
5       Nf3     +1.41/14        0.410   2.33    Qd7     -1.02/13        0.100   1.02
6       Bc4     +1.26/14        0.590   2.92    Nc6     -0.80/15        0.380   1.40
7       O-O     +1.64/16        0.500   3.42    d5      -0.92/14        0.270   1.67
8       Bb5     +1.06/15        0.500   3.92    Bg4     -0.82/12        0.078   1.75
9       Re1     +0.92/15        0.500   4.42    e6      -0.51/15        0.420   2.17
10      Qd3     +0.83/16        0.500   4.92    Bxf3    -0.69/15        0.230   2.40
11      Qxf3    +1.10/16        0.150   5.07    Bd6     -0.57/14        0.120   2.52
12      Qh3     +0.68/18        0.840   5.91    O-O     -0.51/15        0.170   2.69
13      Rxe6    +0.95/18        0.270   6.18    Rfe8    -0.52/16        0.270   2.96
14      Rxe8+   +0.77/18        0.570   6.75    Rxe8    -0.49/16        0.210   3.17
15      Be3     +0.98/19        0.300   7.05    Qxh3    -0.30/17        0.270   3.44
16      gxh3    +0.86/20        0.620   7.67    a6      -0.41/17        0.380   3.82
17      Bxc6    +0.88/19        0.460   8.13    bxc6    -0.43/16        0.170   3.99
18      Rc1     +0.85/17        0.410   8.54    Nd7     -0.57/17        0.440   4.43
19      Ne2     +0.80/18        0.870   9.41    c5      -0.84/16        0.250   4.68
20      dxc5    +0.84/15        0.150   9.56    Bxc5    -0.52/14        0.079   4.76
21      Bxc5    +1.11/18        0.500   10.06   Nxc5    -0.88/18        0.420   5.18
22      Nf4     +1.16/18        0.470   10.53   c6      -0.94/15        0.250   5.43
23      Nd3     +1.00/18        0.880   11.41   Nd7     -0.75/13        0.140   5.57
24      c4      +1.05/17        0.500   11.91   Re2     -0.53/16        0.360   5.93
25      cxd5    +1.22/15        0.140   12.05   cxd5    -0.48/13        0.090   6.02
26      Kf1     +1.72/18        0.860   12.91   Re4     -1.37/16        0.410   6.43
27      Rc8+    +1.56/18        0.500   13.41   Kf7     -1.24/15        0.071   6.50
28      Rc7     +1.52/18        0.160   13.57   Ke8     -1.31/19        0.230   6.73
29      Rxd7    +1.49/20        0.840   14.41   Kxd7    -1.20/19        0.280   7.01
30      Nc5+    +1.72/19        0.150   14.56   Kd6     -1.38/20        0.420   7.43
31      Nxe4+   +1.65/21        0.500   15.06   dxe4    -1.27/16        0.086   7.51
32      h4      +1.69/20        0.620   15.68   g6      -1.48/19        0.410   7.92
33      Ke2     +2.06/21        0.380   16.06   Ke5     -1.65/18        0.210   8.13
34      Ke3     +2.56/21        0.380   16.44   a5      -1.55/18        0.150   8.28
35      b3      +3.11/20        0.390   16.83   Kd5     -2.61/19        0.390   8.67
36      a3      +3.73/20        0.540   17.37   h6      -3.57/19        0.250   8.92
37      b4      +4.84/22        0.480   17.85   axb4    -4.51/18        0.270   9.19
38      axb4    +6.25/20        0.430   18.28   h5      -5.26/19        0.230   9.42
39      Kf4     +12.32/23       0.460   18.74   Kc4     -3.12/18        0.170   9.59
40      Kg5     +25.42/22       0.490   19.23   Kxb4    -13.17/19       0.330   9.92
41      Kxg6    +61.52/30       0.560   19.79   Kc5     -60.39/27       0.250   10.17
42      Kxh5    +72.43/32       0.450   20.24   Kd4     -60.56/26       0.250   10.42
43      Kg6     +M31/31         1.160   21.40   Kd3     -70.93/28       0.230   10.65
44      Kf5     +M27/31         0.360   21.76   Kd2     -72.07/24       0.270   10.92
45      Kxe4    +M23/32         0.200   21.96   Kc3     -M26/27         0.250   11.17
46      h5      +M21/33         0.360   22.32   Kc4     -M22/27         0.089   11.26
47      h6      +M19/33         0.440   22.76   Kb3     -M20/28         0.210   11.47
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Put that PGN into the MRI

Post by Rebel »

With the 2 digit precision PGN I get:

Code: Select all

Depths             MIDG END1 END2 END3     BOOK             TIME
Stockfish_11-64    16.3 19.0 17.7 25.1     3.0 (moves)      0:22.75
Stockfish_11x2-6   14.8 17.0 15.9 21.3     3.0 (moves)      0:11.23
Your PGN must have a 3 digit precision, it explains the 0.24s difference for black.

Hope you are satisfied with the result, after all we are not talking about the 100 meter sprint.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Put that PGN into the MRI

Post by Rebel »

Update : MRI 1.0a

Full version: http://rebel13.nl/dl/mri.zip

Executable and ini file only : http://rebel13.nl/dl/mri-update.7z
90% of coding is debugging, the other 10% is writing bugs.
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Put that PGN into the MRI

Post by Dann Corbit »

TCEC has book moves like this:
{book, mb=+0+0+0+0+0,} sign can be - or + and each 0 can be any number from 0-9
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Rebel
Posts: 6991
Joined: Thu Aug 18, 2011 12:04 pm

Re: Put that PGN into the MRI

Post by Rebel »

Dann Corbit wrote: Wed Feb 19, 2020 10:22 pm TCEC has book moves like this:
{book, mb=+0+0+0+0+0,} sign can be - or + and each 0 can be any number from 0-9
Is there a tool that converts TCEC PGN to normal (say Arena / Cutechess / Chessbase) PGN?

I once had, then they changed the format again, I gave up :D
90% of coding is debugging, the other 10% is writing bugs.
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Put that PGN into the MRI

Post by Dann Corbit »

I am not aware of any, but Les Fernandez wrote a tool that will read it and write out the opening book moves and the analyzed moves as EPD records.
He uses vb.net and regular expressions to parse it.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Put that PGN into the MRI

Post by Guenther »

Rebel wrote: Wed Feb 19, 2020 9:37 pm With the 2 digit precision PGN I get:

Code: Select all

Depths             MIDG END1 END2 END3     BOOK             TIME
Stockfish_11-64    16.3 19.0 17.7 25.1     3.0 (moves)      0:22.75
Stockfish_11x2-6   14.8 17.0 15.9 21.3     3.0 (moves)      0:11.23
Your PGN must have a 3 digit precision, it explains the 0.24s difference for black.

Hope you are satisfied with the result, after all we are not talking about the 100 meter sprint.
Thanks that should be sufficient. Yes, Black had a few 3 digit moves, which is also the default in offficial cutechess for
all moves below 100ms (as shown in the source snipped before).
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy