Some statistics about promotions and underpromotions.

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Ajedrecista
Posts: 2164
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Some statistics about promotions and underpromotions.

Post by Ajedrecista »

Hello Jacob:
jacobbl wrote:I've also seen underpromotion to rook when setting a mate. So I think to get relevant frequencies of the importance of underpromotion, you should remove promotions that are captured in the next move and convert underpromotions that result in a mate (except for knights) to a queen promotion.
I have expanded a little more my tool and now it also searches promotions/underpromotions that give check and checkmate (now my tool spends around 20% to 25% more time to do the new searches). Please take in mind that my results are not exact (as reported by Joined) but very good approximations. OTOH, I do not search promotions/underpromotions that are captured in the next move for two reasons:

a) I only know how to do it when white promotes a pawn but not when black promotes a pawn: I am not a programmer and I search certain text strings inside the PGN file. There is a move number between black promotion/underpromotion and white capture and I do not konw how to handle it.

b) In the case I know how to handle it, the tool will be very slow because it would have to search lots of certain text strings ('a8=Q Kxa8', 'a8=Q+ Kxa8', 'a8=Q Qxa8', ..., 'h8=N+ Nxh8'; 640 strings if I am not wrong, that is, almost nine times slower... and I only get results with white promotions/underpromotions). It is impractical for my poor level tool.

I ran my tool through CCRL-404FRC.[129100].pgn again (there is not an update since 27th May, 2013!):

Code: Select all

[...]

Searching for games and results...

Games:      129100      Estimated remaining time:   542.8 seconds.
  1-0:       54190      Estimated remaining time:   530.1 seconds.
  0-1:       48390      Estimated remaining time:   515.0 seconds.
  1/2-1/2:   26520
  Unknown:       0
______________________________

White score:  52.25%
______________________________

White advantage:    15.62 Elo.
______________________________

Searching promotions and underpromotions...

[...]

61/64  h8=Q    5441     Estimated remaining time:   123.9 seconds.
62/64  h8=R     169     Estimated remaining time:   117.3 seconds.
63/64  h8=B      34     Estimated remaining time:   110.7 seconds.
64/64  h8=N      46     Estimated remaining time:   104.2 seconds.

Promotions/underpromotions to:
  Q:  65056
  R:   2190
  B:    519
  N:   1166

Searching promotions/underpromotions that give check...

1/8   *1=Q+    3048     Estimated remaining time:    97.8 seconds.
2/8   *1=R+      82     Estimated remaining time:    91.3 seconds.
3/8   *1=B+      41     Estimated remaining time:    84.8 seconds.
4/8   *1=N+     139     Estimated remaining time:    78.3 seconds.
5/8   *8=Q+    3356     Estimated remaining time:    71.8 seconds.
6/8   *8=R+     105     Estimated remaining time:    65.2 seconds.
7/8   *8=B+      43     Estimated remaining time:    58.7 seconds.
8/8   *8=N+     128     Estimated remaining time:    52.1 seconds.

Searching promotions/underpromotions that give checkmate...

1/8   *1=Q#     518     Estimated remaining time:    45.6 seconds.
2/8   *1=R#      12     Estimated remaining time:    39.1 seconds.
3/8   *1=B#       0     Estimated remaining time:    32.6 seconds.
4/8   *1=N#       3     Estimated remaining time:    26.1 seconds.
5/8   *8=Q#     521     Estimated remaining time:    19.6 seconds.
6/8   *8=R#      18     Estimated remaining time:    13.0 seconds.
7/8   *8=B#       0     Estimated remaining time:     6.5 seconds.
8/8   *8=N#       7

Approximated elapsed time:   540.8 seconds.

[...]
According to my tool, only (12 + 18)/2190 ~ 1.37% of underpromotions to rook lead to a checkmate in this move... I expected a little more. Here is the complete table:

Code: Select all

(*=Q#)/(*=Q) = (518 + 521)/65056 = 1039/65056 ~ 1.6%
(*=R#)/(*=R) = (12 + 18)/2190 = 30/2190 ~ 1.37%
(*=B#)/(*=B) = (0 + 0)/519 = 0/519 = 0%
(*=N#)/(*=N) = (3 + 7)/1166 = 10/1166 ~ 0.86%

(*=*#)/(*=*) = (518 + 12 + 0 + 3 + 521 + 18 + 0 + 7)/(65056 + 2190 + 519 + 1166) = 1079/68931 ~ 1.57%
IMHO, the majority of rook and bishop underpromotions are captured in the next move; however, I can not parse it. :(

Regards from Spain.

Ajedrecista.
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Some statistics about promotions and underpromotions.

Post by xmas79 »

Ajedrecista wrote:a) I only know how to do it when white promotes a pawn but not when black promotes a pawn: I am not a programmer and I search certain text strings inside the PGN file. There is a move number between black promotion/underpromotion and white capture and I do not konw how to handle it.

b) In the case I know how to handle it, the tool will be very slow because it would have to search lots of certain text strings ('a8=Q Kxa8', 'a8=Q+ Kxa8', 'a8=Q Qxa8', ..., 'h8=N+ Nxh8'; 640 strings if I am not wrong, that is, almost nine times slower... and I only get results with white promotions/underpromotions). It is impractical for my poor level tool.
I think it's fairy easy to extract this by using a regex. Completely untested:

Code: Select all

"([abcdefgh][12345678])\=([QRNB])([\+\#])?"
this would catch ANY black/white promotions in any form of notation. If you want only underpromotion:

Code: Select all

"([abcdefgh][12345678])\=([NB])([\+\#])?"
Simple counting matches gives you the numbers. They are also already divided in groups:
1st group is destination square (a letter between a and h) followed by a number between 1 and 8
this group must be followed by an = sign
2nd group is the promoted piece (a single char among QRBN)
3ds group is check/checkmate sign (that is optional, and thus missing).
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Some statistics about promotions and underpromotions.

Post by sje »

All lines with at least one promotion:

Code: Select all

grep "[abcdefgh][18]\=" games.pgn
All lines with at least one underpromotion:

Code: Select all

grep "[abcdefgh][18]\=[BNR]" games.pgn
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Some statistics about promotions and underpromotions.

Post by xmas79 »

xmas79 wrote:

Code: Select all

"([abcdefgh][12345678])\=([QRNB])([\+\#])?"
I really meant:

Code: Select all

"([abcdefgh][18])\=([QRNB])([\+\#])?"
:oops:

and black/white separation:

white promotions:

Code: Select all

"([abcdefgh][8])\=([QRNB])([\+\#])?"
black promotions:

Code: Select all

"([abcdefgh][1])\=([QRNB])([\+\#])?"
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Some statistics about promotions and underpromotions.

Post by xmas79 »

What about a promotions that give double checks?
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Some statistics about promotions and underpromotions.

Post by sje »

xmas79 wrote:What about a promotions that give double checks?
This can't be determined from a simple textual scan.

When the PGN standard was formed, the consensus was that there be no special markings for double checks or discovered checks.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Some statistics about promotions and underpromotions.

Post by sje »

Also for individual (underpromoting) moves:

Code: Select all

tr " " "\n" < games.pgn | grep "[abcdefgh][18]\=[BNR]"
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

And to find underpromoting checkmates

Post by sje »

And to find underpromoting checkmates:

Code: Select all

grep -v \\[ < games.pgn | tr " " "\n" | grep "[abcdefgh][18]\=[BNR]#"
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

From a collection of 2,262,518 games

Post by sje »

From a collection of 2,262,518 games:

Promotions: 127,835

Promotions to queen: 123,868
Promotions to bishop: 434
Promotions to knight: 2,233
Promotions to rook: 1,300

Promotions with check: 37,529
Promotions with checkmate: 1,084
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: Some statistics about promotions and underpromotions.

Post by xmas79 »

So the game must be replayed and checks must be verified internally...