Does perft include underpromotion?

Discussion of chess software programming and technical issues.

Moderator: Ras

Chan Rasjid
Posts: 588
Joined: Thu Mar 09, 2006 4:47 pm
Location: Singapore

Re: Does perft include underpromotion?

Post by Chan Rasjid »

JVMerlino wrote:
JVMerlino wrote:Your needle is right at the top. :D

Perft 1 is wrong, because there are five legal moves (not four, as shown by your output). You probably aren't counting the en passant capture at d3, which is part of the FEN.

jm
And just to verify, I made a version of my engine that doesn't generate en passant captures, and my perft 1 through perft 5 agree with your numbers. So that is clearly most (if not all) of the problem.

However, my perft 6 is 31753706, whereas yours is 31753730 (difference of 24). But that could be another en passant effect?

jm
Great!

Now I pass all the test positions from "Sharpers" site. The bug is all from my just implemented UCI setboardfen() which did not call atoi() for digit characters. It is indeed the '3' from 'd3' that cause the error.

fen "8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28" :

perft 1 5, nps(0) sec(0.000)
perft 2 117, nps(127000) sec(0.001)
perft 3 3293, nps(1771000) sec(0.002)
perft 4 67197, nps(2118685) sec(0.035)
perft 5 1881089, nps(2610637) sec(0.776)
perft 6 38633283, nps(4937524) sec(8.630)

Can now proceed to the next step :)

Thanks,
Rasjid
User avatar
smrf
Posts: 484
Joined: Mon Mar 13, 2006 11:08 am
Location: Klein-Gerau, Germany

Re: Does perft include underpromotion?

Post by smrf »

Confirmation of those numbers:

Code: Select all

FEN: 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

=>+-a--b--c--d--e--f--g--h-+ MS Vis.Studio C++ 32-Bit-Vers. 14.00
8 |   :::   :::   :::   :::| (Compilation: Apr 28 2010)
7 |:::   :::   :::   :::[p]|
6 |[p]:::   :::   :::[p][b]| Perft Testseries
5 |:::   :::   [k]   :::   | (with TT caching +512.0 MB / 4-fold)
4 |<P>:::[p]<P>[n]:::   :::| TT Access Success +58.0%
3 |:::   ::: * :::   :::   |
2 |<P>:::   :::   :::<P><P>| Smirf Test No.:  0
1 |:::[r]<B>   :::<R><K>   |
  +-a--b--c--d--e--f--g--h-+ Break Time: +10.00 Sec.

Ply        Nodes       all (x)     (ep)           (+)     Prom.  Cstl.     Sec.
-------------------------------------------------------------------------------
1              5             2        1             0         0      0        0
2            117             5        0            12         0      0        0
3           3293           269        0           148         0      0        0
4          67197          4279        0          6019         0      0        0
5        1881089        151494        0         99957      2204      0    0.047
6       38633283       2758216       30       3357855         0      0    0.719
7     1069189070      85602380     1599      58008914   2006568      0    8.328
8    22488501780    1700604632    70647    1927497345     20404      0    80.58
-------------------------------------------------------------------------------
Chan Rasjid
Posts: 588
Joined: Thu Mar 09, 2006 4:47 pm
Location: Singapore

Re: Does perft include underpromotion?

Post by Chan Rasjid »

smrf wrote:Confirmation of those numbers:

Code: Select all

FEN: 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

=>+-a--b--c--d--e--f--g--h-+ MS Vis.Studio C++ 32-Bit-Vers. 14.00
8 |   :::   :::   :::   :::| (Compilation: Apr 28 2010)
7 |:::   :::   :::   :::[p]|
6 |[p]:::   :::   :::[p][b]| Perft Testseries
5 |:::   :::   [k]   :::   | (with TT caching +512.0 MB / 4-fold)
4 |<P>:::[p]<P>[n]:::   :::| TT Access Success +58.0%
3 |:::   ::: * :::   :::   |
2 |<P>:::   :::   :::<P><P>| Smirf Test No.:  0
1 |:::[r]<B>   :::<R><K>   |
  +-a--b--c--d--e--f--g--h-+ Break Time: +10.00 Sec.

Ply        Nodes       all (x)     (ep)           (+)     Prom.  Cstl.     Sec.
-------------------------------------------------------------------------------
1              5             2        1             0         0      0        0
2            117             5        0            12         0      0        0
3           3293           269        0           148         0      0        0
4          67197          4279        0          6019         0      0        0
5        1881089        151494        0         99957      2204      0    0.047
6       38633283       2758216       30       3357855         0      0    0.719
7     1069189070      85602380     1599      58008914   2006568      0    8.328
8    22488501780    1700604632    70647    1927497345     20404      0    80.58
-------------------------------------------------------------------------------
If the generator is the same as that of your actual chess engine, it is faster than mine by x 10.

Rasjid
User avatar
smrf
Posts: 484
Joined: Mon Mar 13, 2006 11:08 am
Location: Klein-Gerau, Germany

Re: Does perft include underpromotion?

Post by smrf »

The speed does not matter here, because it is cached. Moreover it is hard to be compared to other generators, if those do not produce e.g. the information, whether a move is a check or not.
User avatar
smrf
Posts: 484
Joined: Mon Mar 13, 2006 11:08 am
Location: Klein-Gerau, Germany

Re: Does perft include underpromotion?

Post by smrf »

If you might be interested in speed comparison, you could take the following uncached result (32 Bit Intel 2 GHz on iMac BootCamp). Smirf has a legal move generator supplying moves by (+) flags and more, this is comparable to a pseudo-legal generator not supporting such flags. Moreover my analysing perft routine uses six 64 Bit counters, what notably slows down the whole thing.

Code: Select all

FEN: 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

=>+-a--b--c--d--e--f--g--h-+ MS Vis.Studio C++ 32-Bit-Vers. 15.00
8 |   :::   :::   :::   :::| (Compilation: Apr 28 2010)
7 |:::   :::   :::   :::[p]|
6 |[p]:::   :::   :::[p][b]| Perft Testseries
5 |:::   :::   [k]   :::   |
4 |<P>:::[p]<P>[n]:::   :::| (without caching)
3 |:::   ::: * :::   :::   |
2 |<P>:::   :::   :::<P><P>| Smirf Test No.:  0
1 |:::[r]<B>   :::<R><K>   |
  +-a--b--c--d--e--f--g--h-+ Break Time: +25.00 Sec.

Ply        Nodes      all (x)     (ep)         (+)      Prom.   Cstl.      Sec.
-------------------------------------------------------------------------------
1              5            2        1           0          0       0         0
2            117            5        0          12          0       0         0
3           3293          269        0         148          0       0         0
4          67197         4279        0        6019          0       0     0.004
5        1881089       151494        0       99957       2204       0     0.082
6       38633283      2758216       30     3357855          0       0     1.442
7     1069189070     85602380     1599    58008914    2006568       0     36.98
-------------------------------------------------------------------------------