LastEmperor - Chess960 perft tool

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
JohnWoe
Posts: 183
Joined: Sat Mar 02, 2013 10:31 pm

LastEmperor - Chess960 perft tool

Post by JohnWoe » Sat Dec 28, 2019 11:25 am

I notices www.chessprogramming.org has such a nice list of all Chess960 positions. So I stripped a move generator from my engine and made it a (hopefully) useful tool to somebody!

Source code: https://github.com/SamuraiDangyo/LastEmperor
Release: https://github.com/SamuraiDangyo/LastEm ... s/tag/v1.0

Image

Here is a output on the whole suite 512MB hash. No errors. All correct. Took 3 hours on my processor: :P
https://github.com/SamuraiDangyo/bins/b ... _perft.txt

Code: Select all

lastemperor -suite 6
Hash can be adjusted by -hash.

16 MB hash gets 51.716M NPS

Code: Select all

:~$ lastemperor -hash 16 -perft 7
### Perft ( 16 MB ) ###

[ rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 ]
depth          nodes           mnps           time
    0              1          0.000          0.000
    1             20          0.000          0.000
    2            400          0.000          0.000
    3           8902          0.000          0.000
    4         197281         16.440          0.012
    5        4865609         24.574          0.198
    6      119060324         37.797          3.150
    7     3195901860         52.531         60.838

===
depth          nodes           mnps           time
    7     3320034397         51.716         64.198
1024MB hash gets 72.675M NPS

Code: Select all

:~$ lastemperor -hash 1024 -perft 7
### Perft ( 1024 MB ) ###

[ rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 ]
depth          nodes           mnps           time
    0              1          0.000          0.000
    1             20          0.000          0.000
    2            400          0.000          0.000
    3           8902          8.902          0.001
    4         197281         12.330          0.016
    5        4865609         18.430          0.264
    6      119060324         35.194          3.383
    7     3195901860         76.058         42.019

===
depth          nodes           mnps           time
    7     3320034397         72.675         45.683
More

Code: Select all

:~$ lastemperor -hash 1024 -fen "k7/8/2N5/1N6/8/8/8/K6n b - -" -perft 11
### Perft ( 1024 MB ) ###

[ k7/8/2N5/1N6/8/8/8/K6n b - - ]
depth          nodes           mnps           time
    0              1          0.000          0.000
    1              3          0.000          0.000
    2             51          0.000          0.000
    3            345          0.000          0.000
    4           5301          5.301          0.001
    5          38348          7.670          0.005
    6         588695         25.595          0.023
    7        5041119         47.558          0.106
    8       76286462        176.999          0.431
    9      688086116        503.355          1.367
   10    10529852043       1822.089          5.779
   11   100557269878       2684.319         37.461

===
depth          nodes           mnps           time
   11   111857168362       2476.195         45.173

User avatar
Ajedrecista
Posts: 1423
Joined: Wed Jul 13, 2011 7:04 pm
Location: Madrid, Spain.
Contact:

Re: LastEmperor - Chess960 perft tool.

Post by Ajedrecista » Sat Dec 28, 2019 6:16 pm

Hello John:

Very interesting! Thank you very much for your effort. I hope to see someting like this "suite <depth>" but with the starting positions from #1 to #960 and rank them from more nodes to less nodes or something like that.
JohnWoe wrote:
Sat Dec 28, 2019 11:25 am
[...]

Code: Select all

:~$ lastemperor -hash 1024 -fen "k7/8/2N5/1N6/8/8/8/K6n b - -" -perft 11
### Perft ( 1024 MB ) ###

[ k7/8/2N5/1N6/8/8/8/K6n b - - ]
depth          nodes           mnps           time
    0              1          0.000          0.000
    1              3          0.000          0.000
    2             51          0.000          0.000
    3            345          0.000          0.000
    4           5301          5.301          0.001
    5          38348          7.670          0.005
    6         588695         25.595          0.023
    7        5041119         47.558          0.106
    8       76286462        176.999          0.431
    9      688086116        503.355          1.367
   10    10529852043       1822.089          5.779
   11   100557269878       2684.319         37.461

===
depth          nodes           mnps           time
   11   111857168362       2476.195         45.173
In the meantime, I checked your KNNkn example up to perft(11) with JetChess 1.0.0.0 perft counter (test passed!) and computed the following values up to perft(17):

Code: Select all

FEN: k7/8/2N5/1N6/8/8/8/K6n b - -



perft(12):
  1  nh1-f2           515,853,754,000
  2  nh1-g3           556,617,690,659
  3  ka8-b7           466,628,276,107
-------------------------------------
TOTAL:              1,539,099,720,766



perft(13):
  1  nh1-f2         5,048,588,418,268
  2  nh1-g3         5,445,575,825,983
  3  ka8-b7         4,655,797,637,786
-------------------------------------
TOTAL:             15,149,961,882,037



perft(14):
  1  nh1-f2        77,907,389,191,081
  2  nh1-g3        84,639,794,719,193
  3  ka8-b7        71,271,976,743,195
-------------------------------------
TOTAL:            233,819,160,653,469



perft(15):
  1  nh1-f2       781,035,692,757,588
  2  nh1-g3       848,458,665,705,615
  3  ka8-b7       726,873,258,768,157
-------------------------------------
TOTAL:          2,356,367,617,231,360



perft(16):
  1  nh1-f2    12,085,769,515,531,226
  2  nh1-g3    13,206,217,018,587,597
  3  ka8-b7    11,153,010,997,566,568
-------------------------------------
TOTAL:         36,444,997,531,685,391


perft(17):
  1  nh1-f2   123,457,373,557,212,906
  2  nh1-g3   134,886,385,850,843,993
  3  ka8-b7   115,333,700,166,200,528
-------------------------------------
Total:        373,677,459,574,257,427
perft(18) of that position should not overflow 64-bit integers yet although something could be thought to overcome that when present, like in this example from year 2013:

Re: KBNk ---> perft(20) result.

Regards from Spain.

Ajedrecista.

JohnWoe
Posts: 183
Joined: Sat Mar 02, 2013 10:31 pm

Re: LastEmperor - Chess960 perft tool

Post by JohnWoe » Sat Dec 28, 2019 11:17 pm

Thanks for the feedback!

Yes it contains all Chess960 positions:
https://github.com/SamuraiDangyo/LastEm ... er/perft.h
I copied these positions from here: https://www.chessprogramming.org/Chess960_Perft_Results

So that's the LastEmperor's suite. All 960 FENs.
With stronger processor depths 7 and 8 could be solved. Mine took 3 hours just for depth 6.

Code: Select all

lastemperor -suite 8
Yes there's a danger in 64bit overflow. Also 64bit hash signature might collide. Might need 128bit. Also support for multiple cores. So these would be the areas to develop, but I keep my software simple. :P

The reason for this 64bit overflow is because draws are not detected. You would need full history etc.

So this position up to 12. So equal here too.

Code: Select all

./lastemperor -hash 512 -fen "k7/8/2N5/1N6/8/8/8/K6n b - -" -perft 12
### Perft ( 512 MB ) ###

[ k7/8/2N5/1N6/8/8/8/K6n b - - ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1               3           0.000           0.000
    2              51           0.000           0.000
    3             345           0.345           0.001
    4            5301           0.000           0.000
    5           38348           9.587           0.004
    6          588695          25.595           0.023
    7         5041119          49.423           0.102
    8        76286462         190.716           0.400
    9       688086116         549.151           1.253
   10     10529852043        1909.311           5.515
   11    100557269878        2706.718          37.151
   12   1539099720766        4666.399         329.826

===
depth           nodes            mnps            time
   12   1650956889128        4411.080         374.275

User avatar
Ajedrecista
Posts: 1423
Joined: Wed Jul 13, 2011 7:04 pm
Location: Madrid, Spain.
Contact:

Re: LastEmperor - Chess960 perft tool.

Post by Ajedrecista » Tue Dec 31, 2019 11:06 am

Hello John:
JohnWoe wrote:
Sat Dec 28, 2019 11:17 pm
Thanks for the feedback!

Yes it contains all Chess960 positions:
https://github.com/SamuraiDangyo/LastEm ... er/perft.h
I copied these positions from here: https://www.chessprogramming.org/Chess960_Perft_Results

So that's the LastEmperor's suite. All 960 FENs.
With stronger processor depths 7 and 8 could be solved. Mine took 3 hours just for depth 6.

Code: Select all

lastemperor -suite 8
[...]
I think I did not make my point clear. Positions from Chess Programming Wiki (as they are at 2019/12/31) are not starting positions themselves, they are positions after 8 moves (maybe plies?) played at random, like the intro of the article suggests. Your verification of that test suite is great, though I was pointing out to other direction: the 960 starting positions. The following threads are courtesy of Mike B:

Strictly for Chess960 Enthusiasts ...

Chess960 Generator and Lookup Tool

Code: Select all

bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w KQkq - 0 1
bqnbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BQNBNRKR w KQkq - 0 1
bqnnrbkr/pppppppp/8/8/8/8/PPPPPPPP/BQNNRBKR w KQkq - 0 1
[...]
Castling rights might need a modification, like replacing KQkq by the files where there are rooks in the starting positions, from right to left:

Code: Select all

bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w HFhf - 0 1
bqnbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BQNBNRKR w HFhf - 0 1
bqnnrbkr/pppppppp/8/8/8/8/PPPPPPPP/BQNNRBKR w HEhe - 0 1
[...]
The numbering scheme might be a little different between Chess Programming Wiki (CPW) positions and what I posted (Mike's tool, who followed Scharnagl's methods described at Wikipedia). CPW seems to use a different scheme than Wikipedia (Scharnagl's methods):

Code: Select all

In ascent order:

  #       CPW:      Scharnagl:
------------------------------
   0      N/A        BBQNNRKR
   1    BQNBNRKR     BQNBNRKR
   2    BQNNRBKR     BQNNRBKR
[...]    [...]        [...]
 959    RKRNNQBB     RKRNNQBB
 960    BBQNNRKR       N/A
The only difference I was able to see is that CPW #960 is called #0 under Scharnagl's methods.

Anyway, I was thinking in Perft(1), Perft(2), ... of the 960 starting positions:

Code: Select all

Perft(1) = 18 for the positions with four knights on the corners.
Perft(1) = 19 for the positions with two knights (one by side) on the corners.
Perft(1) = 20 for the positions without knights on the corners.

Perft(2) = [Perft(1)]²
And following Perft(n) values should have lower branching factors Perft(n)/Perft(n-1) than CPW test suite (like in normal chess, where branching factor has a raising tendency from the first plies), so this could speed up a little the calculations since there should be fewer nodes to count.

Other than that, thanks again for your effort.

Regards from Spain.

Ajedrecista.

JohnWoe
Posts: 183
Joined: Sat Mar 02, 2013 10:31 pm

Re: LastEmperor - Chess960 perft tool

Post by JohnWoe » Tue Dec 31, 2019 5:30 pm

Hello.
Thanks for the feedback!

I added all Chess960 starting positions. With nodes: depth 0 -> depth 6.

I wrote a Chess960 generator myself and generated all 960 positions and put them in here: https://github.com/SamuraiDangyo/LastEm ... erft.h#L10

To me seems legit.

Here are the other verify Chess960 positions: https://github.com/SamuraiDangyo/LastEm ... rft.h#L979

Done 0 -> 6 depths: https://github.com/SamuraiDangyo/bins/b ... uite_6.txt

Id test is just those chessprogramming.org 960 positions up to depth 6.

lastemperor -id

Code: Select all

### Chess960 id test ( 256 MB ) ###
[ 1: bqnb1rkr/pp3ppp/3ppn2/2p5/5P2/P2P4/NPP1P1PP/BQ1BNRKR w HFhf - 2 9 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              21           0.000           0.000
    2             528           0.000           0.000
    3           12189           0.000           0.000
    4          326672          18.148           0.018
    5         8146062          23.889           0.341
    6       227689589          43.560           5.227

[ 2: 2nnrbkr/p1qppppp/8/1ppb4/6PP/3PP3/PPP2P2/BQNNRBKR w HEhe - 1 9 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              21           0.000           0.000
    2             807           0.000           0.000
    3           18002          18.002           0.001
    4          667366          19.068           0.035
    5        16253601          23.153           0.702
    6       590751109          47.139          12.532

[ 3: b1q1rrkb/pppppppp/3nn3/8/P7/1PPP4/4PPPP/BQNNRKRB w GE - 1 9 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              20           0.000           0.000
    2             479           0.000           0.000
    3           10471           0.000           0.000
    4          273318          18.221           0.015
    5         6417013          24.681           0.260
    6       177654692          41.850           4.245

[ 4: qbbnnrkr/2pp2pp/p7/1p2pp2/8/P3PP2/1PPP1KPP/QBBNNR1R w hf - 0 9 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              22           0.000           0.000
    2             593           0.000           0.000
    3           13440          13.440           0.001
    4          382958          17.407           0.022
    5         9183776          22.676           0.405
    6       274103539          44.132           6.211

[ 5: 1nbbnrkr/p1p1ppp1/3p4/1p3P1p/3Pq2P/8/PPP1P1P1/QNBBNRKR w HFhf - 0 9 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              28           0.000           0.000
    2            1120           1.120           0.001
    3           31058          31.058           0.001
    4         1171749          18.599           0.063
    5        34030312          25.226           1.349
    6      1250970898          48.811          25.629

....
lastemperor -suite 6

Code: Select all

### Chess960 test suite ( 256 MB ) ###
[ 1: rkqrbbnn/pppppppp/8/8/8/8/PPPPPPPP/RKQRBBNN w DAda - 0 1 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              19           0.000           0.000
    2             361           0.000           0.000
    3            7678           0.000           0.000
    4          162755          18.084           0.009
    5         3871700          21.874           0.177
    6        91540671          34.182           2.678

[ 2: rkqrbnnb/pppppppp/8/8/8/8/PPPPPPPP/RKQRBNNB w DAda - 0 1 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              20           0.000           0.000
    2             400           0.000           0.000
    3            8838           0.000           0.000
    4          194525          17.684           0.011
    5         4738058          22.244           0.213
    6       114586864          35.096           3.265

[ 3: rkqrnbbn/pppppppp/8/8/8/8/PPPPPPPP/RKQRNBBN w DAda - 0 1 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              19           0.000           0.000
    2             361           0.000           0.000
    3            7782           0.000           0.000
    4          166301          16.630           0.010
    5         3956472          21.620           0.183
    6        93289372          34.022           2.742

[ 4: rkqrnnbb/pppppppp/8/8/8/8/PPPPPPPP/RKQRNNBB w DAda - 0 1 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              20           0.000           0.000
    2             400           0.000           0.000
    3            8948           0.000           0.000
    4          198454          18.041           0.011
    5         4844522          22.021           0.220
    6       117181441          34.577           3.389

[ 5: rkqbrnbn/pppppppp/8/8/8/8/PPPPPPPP/RKQBRNBN w EAea - 0 1 ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              19           0.000           0.000
    2             361           0.000           0.000
    3            7727           7.727           0.001
    4          163964          18.218           0.009
    5         3883643          20.993           0.185
    6        91239486          32.796           2.782

...

JohnWoe
Posts: 183
Joined: Sat Mar 02, 2013 10:31 pm

Re: LastEmperor - Chess960 perft tool

Post by JohnWoe » Tue Dec 31, 2019 6:15 pm

Here is hash size effects. I made minimum hash size to 1 MB. If there is collisions then 1 MB should be used. Otherwise half of the available RAM?

All done w/ profile built LastEmperor.

1 MB hash.

Code: Select all

lastemperor -fen "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w" -hash 1 -perft 8
### Perft ( 1 MB ) ###

[ 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              14           0.000           0.000
    2             191           0.191           0.001
    3            2812           0.000           0.000
    4           43238          21.619           0.002
    5          674624          29.331           0.023
    6        11030083          44.298           0.249
    7       178633661          52.355           3.412
    8      3009794393          57.333          52.497

===
total      3200179017          56.959          56.184
16 MB hash.

Code: Select all

lastemperor -fen "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w" -hash 16 -perft 8
### Perft ( 16 MB ) ###

[ 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              14           0.000           0.000
    2             191           0.000           0.000
    3            2812           2.812           0.001
    4           43238          14.413           0.003
    5          674624          23.263           0.029
    6        11030083          48.591           0.227
    7       178633661          96.925           1.843
    8      3009794393         175.008          17.198

===
total      3200179017         165.804          19.301
512 MB hash.

Code: Select all

lastemperor -fen "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w" -hash 555 -perft 8
### Perft ( 512 MB ) ###

[ 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w ]
depth           nodes            mnps            time
    0               1           0.000           0.000
    1              14           0.000           0.000
    2             191           0.000           0.000
    3            2812           0.000           0.000
    4           43238           8.648           0.005
    5          674624          16.454           0.041
    6        11030083          34.905           0.316
    7       178633661          87.011           2.053
    8      3009794393         219.341          13.722

===
total      3200179017         198.313          16.137

Post Reply