Short Games Analyzer Tool released

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Short Games Analyzer Tool released

Post by pohl4711 »

I made a new tool: Short Games Analyzer Tool

https://www.sp-cc.de/files/short_games_analyzer_tool.7z

It builds very detailed statistics-files out of the short games (up to 60 moves), engines or players played (out of a pgn-file of games).

The SGA-tool writes a statistics-file: SGA_full_statistics.txt
In this file, the percent numbers of all short games (wins/draws/losses, not longer than 60 moves) of each engine/player are stored (percents compared to the overall number of won games/draws/losses of this engine/player.) And below the percent values, the absolute numbers of games are stored.
Additionally all short win games are searched for sacrifices and the statistics for theses sac-games follow below the normal short wins.

Code: Select all

The ouput for one engine (full statistic) looks like this:
************************************************************************************************
*** Rank 1: "Velvet 4.0.0 avx2"  All games: 5000 (1109 wins / 2498 draws / 1393 losses)
*** Overall score: 47.16%     Overall draw-rate: 49.96%
*** Average game length: All: 78 moves (wins: 78 moves / draws: 76 moves / losses: 80 moves) 
************************************************************************************************
*** all short wins   wins0-30   wins31-35  wins36-40  wins41-45  wins46-50  wins51-55  wins56-60
*** --------------------------------------------------------------------------------------------
***    [15.24%] =    [00.00%  +  00.09%  +  00.18%  +  00.90%  +  02.34%  +  04.33%  +  07.39%]
***    [   169] =    [     0  +       1  +       2  +      10  +      26  +      48  +      82]
*** --------------------------------------------------------------------------------------------
*** all short sacs  sacs queen   sacs 5+p   sacs 4p    sacs 3p    sacs 2p    sacs 1p(=pawn-unit) 
*** --------------------------------------------------------------------------------------------
***    [03.07%] =    [00.00%  +  00.00%  +  00.09%  +  00.36%  +  00.45%  +  02.16%]
***    [    34] =    [     0  +       0  +       1  +       4  +       5  +      24]
************************************************************************************************
*** all short draws  draw0-30   draw31-35  draw36-40  draw41-45  draw46-50  draw51-55  draw56-60
*** --------------------------------------------------------------------------------------------
***    [32.63%] =    [03.56%  +  02.00%  +  02.68%  +  04.24%  +  05.20%  +  06.65%  +  08.29%]
***    [   815] =    [    89  +      50  +      67  +     106  +     130  +     166  +     207]
************************************************************************************************
*** all short losses loss0-30   loss31-35  loss36-40  loss41-45  loss46-50  loss51-55  loss56-60
*** --------------------------------------------------------------------------------------------
***    [16.01%] =    [00.00%  +  00.00%  +  00.00%  +  00.43%  +  01.87%  +  05.10%  +  08.61%]
***    [   223] =    [     0  +       0  +       0  +       6  +      26  +      71  +     120]
************************************************************************************************
So, it is easy to see, how much short wins or losses an engine/player has (splitted into7 move-intervals from (0-30) up tp (56-60) moves and with an overall percent score.). And if (and how much) short wins of the engine/player contain a sacrifice.

Mention: The numbers in the "Average game length:"-line are the average length values of all games, the engine has played in the source pgn-file, no matter how long the games were and if they ended before endgame or not. Same for the Overall score and the Overall draw-rate values.

The engine/players in the SGA_full_statistics.txt-file are sorted by: (percent all short wins)-(percent all short draws)-(percent all short losses)

Additionally, the tool writes 3 statistics.txt-files separately for wins/draws/losses:
SGA_wins_statistics.txt, SGA_draws_statistics.txt, SGA_losses_statistics.txt
In there, the engine/players are sorted by (percent all short wins) or (percent all short draws) or (percent all short wins), but, because short wins are a good thing and short draws and losses are not, the short draws and short losses are sorted reversed (smallest number at the top of the file).
And the tool writes a pgn-file with all short wins (up to 60 moves) followed by all short draws: shortgames.pgn (or shortgames_no_endgame.pgn)
And all short win games with a sacrifice are stored in the file short_sac_games.pgn  (or short_sac_games_no_endgame.pgn) (sorted top-down: Highest sacs first, lowest behind..).
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: Short Games Analyzer Tool released

Post by Ozymandias »

Not sure that the program it relies on will give you the desired results. pgn-extract has problem with --markmatches (positions not on file are identified as a match) and the -z flag, which doesn't pick up on all positions, or does very late in the game. Probably both problems are interrelated.
User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Short Games Analyzer Tool released

Post by pohl4711 »

I use -y
This works fine. I already use it in my EAS-tools and my Sacrifice Game Search tools.
Earlier pgn-extract had a promotion-bug in piece pattern searching. Latest versions are fixed.

I use -z only for finding endgames in games. And this works, too. I looked at many testgames, could not find any bug.
If you have an example for bugs in pgn-extract (new version), please share it.
You can use the pgn-extract binary, I use in my tools: it is in the bin-folder of all tools: The binary is smaller and +30% faster, than pgn-extract from the authors website.
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: Short Games Analyzer Tool released

Post by Ozymandias »

Here's an example.

Applying the following command, trough either your version of pgn-extract, or the latest (22-07), you get the smaller PGN out of the other:

pgn-extract -zvars --markmatches MATCH -o out.pgn in.pgn

The "vars" file, with all 7-men positions, is also included for your perusal.

Out of 11 games, 1 is correctly detected, 1 is completely left out and in the other 9 cases, a position not on file is identified as a MATCH for a 7-men, when they're actually 5 & 6-men positions.
User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Short Games Analyzer Tool released

Post by pohl4711 »

Ozymandias wrote: Fri Aug 05, 2022 5:04 pm Here's an example.

Applying the following command, trough either your version of pgn-extract, or the latest (22-07), you get the smaller PGN out of the other:

pgn-extract -zvars --markmatches MATCH -o out.pgn in.pgn

The "vars" file, with all 7-men positions, is also included for your perusal.

Out of 11 games, 1 is correctly detected, 1 is completely left out and in the other 9 cases, a position not on file is identified as a MATCH for a 7-men, when they're actually 5 & 6-men positions.
Perhaps the problem is, that your vars file contains patterns like bbb for 3 bishops. Instead of b3, which is the correct writing for 3 bishops referring to pgn-extract readme. Of course, bbb should work, too. But this could be the bug/problem. Perhaps.

My endgame-filter for example looks like this (l stands for knight or bishop)
00 r1-l3-p4- r1-l3-p4-
00 r1-l3-p4- r2-l2-p4-
00 r1-l3-p4- q1-l3-p4-
00 r1-l3-p4- q1-r1-l1-p4-
00 r2-l2-p4- r2-l2-p4-
00 r2-l2-p4- q1-l3-p4-
00 r2-l2-p4- q1-r1-l1-p4-
00 q1-l3-p4- q1-l3-p4-
00 q1-l3-p4- q1-r1-l1-p4-
00 q1-r1-l1-p4- q1-r1-l1-p4-
00 r1-l2-p7- r1-l2-p7-
00 r1-l2-p7- r2-l1-p7-
00 r1-l2-p7- q1-l2-p7-
00 r1-l2-p7- q1-r1-p7-
00 r2-l1-p7- r2-l1-p7-
00 r2-l1-p7- q1-l2-p7-
00 r2-l1-p7- q1-r1-p7-
00 q1-l2-p7- q1-l2-p7-
00 q1-l2-p7- q1-r1-p7-
00 q1-r1-p7- q1-r1-p7-

I could not find any mismatches using this filter or others (in my sacrifice game search tools).
User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Short Games Analyzer Tool released

Post by pohl4711 »

OK, there is a problem. But I think a size-problem, mainly.

If I change rpp rp in your file to rp2 rp, this does not work, too.
But, if I use an empty file with one line only:
00 rp2 rp
Then it works fine.

So, I believe, your vars-file is just too long for pgn-extract (more than 1000 lines!)
My longest piece-pattern file has 152 lines.
User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Short Games Analyzer Tool released

Post by pohl4711 »

I found, that the piece pattern are working. Only the markmatch seems buggy:

If I cut the first of your games after 125 moves, then it is found correctly (using your vars file) as rpp pp (and the match is correct, too (after move 118)).

Thats good for me, because only my Sacrifice Games Search Comfort tool uses the markmatch option. All other tools use just the piece pattern for finding the games, not marking anything in them.
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Post by Ozymandias »

Taking all those variables into account I performed several experiments, these are my conclusions:
  • The number of lines in the vars file can be 1001, at least.
  • The length of the games makes no apparent difference.
  • Both the piece recognition and the "markmatching" work equally "well".
  • To be on the safe side, I used the formatting you suggested.
  • You need to include kings when only one side has pieces, despite being supposedly redundant.
  • Games where the maximum number of pieces was reached on the very last move, wont be neither recognized nor marked.
User avatar
pohl4711
Posts: 2388
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Short Games Analyzer Tool released

Post by pohl4711 »

I wrote an email to David Barnes and linked this thread.
He answered very quickly and promised to investigate the problem next week.
User avatar
Ozymandias
Posts: 1529
Joined: Sun Oct 25, 2009 2:30 am

Re: Short Games Analyzer Tool released

Post by Ozymandias »

He told me the same thing, he must've gotten both mails at roughly the same time (I also emailed him with that information).