An altenative perft() initial FEN

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

An altenative perft() initial FEN

Post by sje »

Instead of starting a perft() run from the initial array, an alternative position can be used to provide better variety of moves while also remaining symmetric regarding color.

The one is use is: [d]r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10[/d]

I've adjusted the path counter to report both total processor time and total wall time.

On a quad core 2.66 GHz Xeon:

Code: Select all

Mt(Full 0): 1   Proc: 0.000   Wall: 0.000   Frequency: inf   Period: 0
Mt(Full 1): 46   Proc: 0.008   Wall: 0.109   Frequency: 421.06   Period: 0.00237496
Mt(Full 2): 2079   Proc: 0.009   Wall: 0.109   Frequency: 18976.8   Period: 5.2696e-05
Mt(Full 3): 89890   Proc: 0.044   Wall: 1.216   Frequency: 73863.4   Period: 1.35385e-05
Mt(Full 4): 3894594   Proc: 1.420   Wall: 1.221   Frequency: 3.18951e+06   Period: 3.13528e-07
Mt(Full 5): 164075551   Proc: 1:00.462   Wall: 16.700   Frequency: 9.82461e+06   Period: 1.01785e-07

Mt(Bulk 0): 1   Proc: 0.000   Wall: 0.000   Frequency: inf   Period: 0
Mt(Bulk 1): 46   Proc: 0.008   Wall: 0.109   Frequency: 418.692   Period: 0.00238839
Mt(Bulk 2): 2079   Proc: 0.008   Wall: 0.109   Frequency: 19000.5   Period: 5.26301e-05
Mt(Bulk 3): 89890   Proc: 0.009   Wall: 0.109   Frequency: 821026   Period: 1.21799e-06
Mt(Bulk 4): 3894594   Proc: 0.067   Wall: 1.221   Frequency: 3.18814e+06   Period: 3.13663e-07
Mt(Bulk 5): 164075551   Proc: 2.313   Wall: 1.221   Frequency: 1.34294e+08   Period: 7.44635e-09
Mt(Bulk 6): 6923051137   Proc: 1:43.772   Wall: 27.486   Frequency: 2.51872e+08   Period: 3.97027e-09

Mt(Tran 0): 1   Proc: 0.000   Wall: 0.000   Frequency: inf   Period: 0
Mt(Tran 1): 46   Proc: 0.008   Wall: 0.109   Frequency: 419.926   Period: 0.00238137
Mt(Tran 2): 2079   Proc: 0.008   Wall: 0.109   Frequency: 18962.4   Period: 5.27359e-05
Mt(Tran 3): 89890   Proc: 0.010   Wall: 0.109   Frequency: 819379   Period: 1.22044e-06
Mt(Tran 4): 3894594   Proc: 0.068   Wall: 1.221   Frequency: 3.18942e+06   Period: 3.13536e-07
Mt(Tran 5): 164075551   Proc: 1.316   Wall: 1.220   Frequency: 1.34454e+08   Period: 7.43751e-09
Mt(Tran 6): 6923051137   Proc: 31.709   Wall: 8.720   Frequency: 7.93856e+08   Period: 1.25967e-09
Mt(Tran 7): 287188994746   Proc: 8:34.911   Wall: 2:11.415   Frequency: 2.18535e+09   Period: 4.57594e-10
User avatar
Ajedrecista
Posts: 1952
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: An altenative perft() initial FEN.

Post by Ajedrecista »

Hi Steven:

[d]r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10

Perft(8) with JetChess 1.0.0.0 (1 GB of hash). Intel Pentium D930 (3 GHz).

Code: Select all

  1  Qe2-d1  234167617426
  2  Qe2-e3  308842023528
  3  Qe2-d2  295868930380
  4  Qe2-e1  248416588794
  5  Ra1-a2  219910819221
  6  Ra1-b1  244344394201
  7  Ra1-c1  228756732529
  8  Ra1-d1  217033021864
  9  Ra1-e1  191324612040
 10  Rf1-e1  278391795980
 11  Rf1-d1  279866539575
 12  Rf1-c1  262975984879
 13  Rf1-b1  250455068576
 14  Bc4-b5  252853963972
 15  Bc4*a6  266411463049
 16  Bc4-d5  237745387268
 17  Bc4-e6  285586639501
 18  Bc4*f7   27840285856
 19  Bc4-b3  243445458227
 20  Bc4-a2  243830203635
 21  Bg5*f6  210091588312
 22  Bg5-h6  276696805010
 23  Bg5-h4  229275262647
 24  Bg5-f4  345712263540
 25  Bg5-e3  298954728547
 26  Bg5-d2  274926958289
 27  Bg5-c1  220870148919
 28  Nc3-a4  247622346749
 29  Nc3-b5  272954987107
 30  Nc3-d5  260276085890
 31  Nc3-a2  232369871568
 32  Nc3-b1  182334597137
 33  Nc3-d1  169676078575
 34  Nf3-d4  357452428358
 35  Nf3*e5  457843968833
 36  Nf3-h4  276769253596
 37  Nf3-d2  261022988465
 38  Nf3-e1  184236993194
 39   b2-b3  239012043652
 40   b2-b4  264214109378
 41   g2-g3  286044117401
 42   h2-h3  317670775089
 43   h2-h4  271689917931
 44   a3-a4  284751983301
 45   d3-d4  339913662701
 46  Kg1-h1  343138348836

Total:     11923589843526

11,923,589,843,526 (move pathes after 8 half moves).

Time: 9278.506 s (2:34:38.506).
I also ran a MonteCarlo perft(9) estimate using Nebiyu 1.42:

Code: Select all

[...]

<000000023843> setboard r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10
<000000026843> seed 0
seed 1373538860
<000000032671> perftmc 9
1.&#123;4.901429e+014&#125; 4.901429e+014 +- 0.000000e+000 990913 0.00 sec
2.&#123;4.895282e+014&#125; 4.898355e+014 +- 2.173481e+011 1981826 0.00 sec
3.&#123;4.906414e+014&#125; 4.901042e+014 +- 2.628686e+011 2972735 0.00 sec

&#91;...&#93;

503.&#123;4.897736e+014&#125; 4.901690e+014 +- 1.821891e+010 498429025 0.00 sec
504.&#123;4.900149e+014&#125; 4.901687e+014 +- 1.818532e+010 499419938 0.00 sec
505.&#123;4.901232e+014&#125; 4.901686e+014 +- 1.814954e+010 500410851 0.00 sec
time 7570.84 sec
With 95% confidence: perft(9) ~ 4.901686e+14 ± 1.959964*1.814954e+10 ~ ]4.901330e+14, 4.902042e+14[.

I computed unique positions at some plies with JetChess as a bonus:

Code: Select all

Positions&#40;0&#41; =           1
Positions&#40;1&#41; =          46
Positions&#40;2&#41; =       2,079
Positions&#40;3&#41; =      49,377
Positions&#40;4&#41; =   1,164,752
Positions&#40;5&#41; =  19,106,668
Positions&#40;6&#41; = 315,668,837
I ran perft(8) and positions(6) simultaneously, so due to lack of RAM (only 2 GB), I had to do the count of positions(6) with 320 MB of hash and 32 steps, instead of the faster setting of 1.25 GB of hash and 8 steps. Positions(6) took 3760.239 seconds (1:02:40.239). Positions(7) is impossible for JetChess due to hash overflows. I did not forget to tick the en passant flag this time! :)

Regards from Spain.

Ajedrecista.
ankan
Posts: 77
Joined: Sun Apr 21, 2013 3:29 pm
Full name: Ankan Banerjee

Re: An altenative perft() initial FEN

Post by ankan »

perft_gpu:

Code: Select all

GPU Perft 1&#58; 46,   Time taken&#58; 2.2016e-005 seconds, nps&#58; 2089389

GPU Perft 2&#58; 2079,   Time taken&#58; 0.000141536 seconds, nps&#58; 14688842

GPU Perft 3&#58; 89890,   Time taken&#58; 0.000381088 seconds, nps&#58; 235877284

GPU Perft 4&#58; 3894594,   Time taken&#58; 0.00167398 seconds, nps&#58; 2326541879

GPU Perft 5&#58; 164075551,   Time taken&#58; 0.0103256 seconds, nps&#58; 15890171635

GPU Perft 6&#58; 6923051137,   Time taken&#58; 0.440964 seconds, nps&#58; 15699824779

GPU Perft 7&#58; 287188994746,   Time taken&#58; 18.1378 seconds, nps&#58; 15833732599

GPU Perft 8&#58; 11923589843526,   Time taken&#58; 783.101 seconds, nps&#58; 15226116412
ibid
Posts: 89
Joined: Mon Jun 13, 2011 12:09 pm

Re: An altenative perft() initial FEN.

Post by ibid »

Ajedrecista wrote:With 95% confidence: perft(9) ~ 4.901686e+14 ± 1.959964*1.814954e+10 ~ ]4.901330e+14, 4.902042e+14[.
I'm going with 490,154,852,788,714 for perft(9)... :)

-paul
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: An altenative perft() initial FEN

Post by sje »

Maybe this position and its perft() results should be added to the wiki.

The multithreaded perft() code in the Symbolic re-write uses condition variables, something that wasn't done in the prior version which used polling. I had hoped for a slight speed-up, but any improvement is down in the noise level.

Also, I note that a pthread mutex used in conjunction with a pthread_cond_wait() call must not be initialized with an error checking attribute. No where is this documented as far as I have seen.
Angrim
Posts: 97
Joined: Mon Jun 25, 2012 10:16 pm
Location: Forks, WA
Full name: Ben Nye

Re: An altenative perft() initial FEN

Post by Angrim »

I would prefer the position before any castling, for testing purposes. It's important that your movegen be able to correctly generate castling moves.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: An altenative perft() initial FEN

Post by sje »

On the 3.4 GHz i7-2600 with a small transposition table:

Code: Select all

Mt&#40;Tran 0&#41;&#58; 1   Proc&#58; 0.000   Wall&#58; 0.000   Frequency&#58; inf   Period&#58; 0
Mt&#40;Tran 1&#41;&#58; 46   Proc&#58; 0.004   Wall&#58; 0.013   Frequency&#58; 3328.51   Period&#58; 0.000300435
Mt&#40;Tran 2&#41;&#58; 2079   Proc&#58; 0.004   Wall&#58; 0.014   Frequency&#58; 147415   Period&#58; 6.78355e-06
Mt&#40;Tran 3&#41;&#58; 89890   Proc&#58; 0.004   Wall&#58; 0.014   Frequency&#58; 6.25713e+06   Period&#58; 1.59818e-07
Mt&#40;Tran 4&#41;&#58; 3894594   Proc&#58; 0.100   Wall&#58; 0.068   Frequency&#58; 5.71038e+07   Period&#58; 1.7512e-08
Mt&#40;Tran 5&#41;&#58; 164075551   Proc&#58; 1.456   Wall&#58; 0.218   Frequency&#58; 7.52047e+08   Period&#58; 1.3297e-09
Mt&#40;Tran 6&#41;&#58; 6923051137   Proc&#58; 35.350   Wall&#58; 4.530   Frequency&#58; 1.52814e+09   Period&#58; 6.54389e-10
Mt&#40;Tran 7&#41;&#58; 287188994746   Proc&#58; 10&#58;12.734   Wall&#58; 1&#58;18.197   Frequency&#58; 3.67262e+09   Period&#58; 2.72285e-10
Mt&#40;Tran 8&#41;&#58; 11923589843526   Proc&#58; 5&#58;09&#58;03.638   Wall&#58; 39&#58;20.872   Frequency&#58; 5.0505e+09   Period&#58; 1.98e-10
The Symbolic re-write needs to understand how to put commas in long integer output.
ankan
Posts: 77
Joined: Sun Apr 21, 2013 3:29 pm
Full name: Ankan Banerjee

Re: An altenative perft() initial FEN.

Post by ankan »

ibid wrote:
Ajedrecista wrote:With 95% confidence: perft(9) ~ 4.901686e+14 ± 1.959964*1.814954e+10 ~ ]4.901330e+14, 4.902042e+14[.
I'm going with 490,154,852,788,714 for perft(9)... :)

-paul
Agreed,
GPU Perft 9: 490154852788714, Time taken: 31980.9 seconds, nps: 15326506316
User avatar
Ajedrecista
Posts: 1952
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: An altenative perft() initial FEN.

Post by Ajedrecista »

Hello:
Angrim wrote:I would prefer the position before any castling, for testing purposes. It's important that your movegen be able to correctly generate castling moves.
[d]r3k2r/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R3K2R w KQkq - 0 9

I did not save the divided results, only the final ones:

Code: Select all

Perft&#40;0&#41; =                  1
Perft&#40;1&#41; =                 47
Perft&#40;2&#41; =              2,163
Perft&#40;3&#41; =             96,107
Perft&#40;4&#41; =          4,258,053
Perft&#40;5&#41; =        183,542,501
Perft&#40;6&#41; =      7,891,984,336
Perft&#40;7&#41; =    332,402,867,326
Perft&#40;8&#41; = 13,966,485,919,552

Code: Select all

Positions&#40;0&#41; =           1
Positions&#40;1&#41; =          47
Positions&#40;2&#41; =       2,163
Positions&#40;3&#41; =      53,768
Positions&#40;4&#41; =   1,319,596
Positions&#40;5&#41; =  22,855,611
Positions&#40;6&#41; = 394,982,024
Finally, I did a MonteCarlo perft estimate using Nebiyu 1.42:

Code: Select all

perftmc 9
 m = 5.781523e+014
sd = 2.434931e+010
With 95% confidence: m ± 1.959964*sd ~ 5.781523e+14 ± 1.959964*2.434931e+10 ~ ]5.781046e+14, 5.782000+14[. I hope no typos.

Regards from Spain.

Ajedrecista.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: An altenative perft() initial FEN.

Post by sje »

ibid wrote:
Ajedrecista wrote:With 95% confidence: perft(9) ~ 4.901686e+14 ± 1.959964*1.814954e+10 ~ ]4.901330e+14, 4.902042e+14[.
I'm going with 490,154,852,788,714 for perft(9)... :)
After 22+ hours of wall time (7+ days hyperthread time), Symbolic says:

Code: Select all

Mt&#40;Tran 9&#41;&#58; 490154852788714   Proc&#58; 7&#58;09&#58;50&#58;16.543   Wall&#58; 22&#58;35&#58;55.794   Frequency&#58; 6.02483e+09   Period&#58; 1.6598e-10