Page 1 of 1

perft question

PostPosted: 19 Jan 2005, 00:40
by Sven Schüle
Hi,

I have a question about perft. If a mate or draw (e.g. stalemate) occurs at depth D with D < MAX_DEPTH and I am calculating perft(MAX_DEPTH), does this leaf node count for the perft number or not? Note that I mean the real perft number, not the total number of nodes visited.

On http://homepages.caverock.net.nz/~peter/perft.htm, Peter McKenzie states:
If a checkmate or stalemate is reached before the specified depth is reached then of course that branch of the search tree will not reach the specified depth.

and later on:
The result of a perft search is the number of nodes reached at the specified depth.


I have the impression that such nodes do not count but I want to be sure. I have implemented perft for Surprise now, but my numbers are slightly different, and it seems to be related to mate positions.

Cheers,
Sven

Re: perft question

PostPosted: 19 Jan 2005, 00:47
by Zach Wegner
No, they do not count.

Re: perft question

PostPosted: 19 Jan 2005, 00:49
by Reinhard Scharnagl
Perft counts all VALID moves within a ply. A VALID mating move still is a move. Thus not all pseudolegal mating moves will be counted, only the LEGAL will be.

Reinhard.

Re: perft question

PostPosted: 19 Jan 2005, 00:55
by Alessandro Scotti
Sven Sch?le wrote:I have implemented perft for Surprise now, but my numbers are slightly different, and it seems to be related to mate positions.


Hi Sven,
note that Reinhard's statistics show the perft numbers classified per move type... very helpful for debugging!

Thank you

PostPosted: 19 Jan 2005, 09:25
by Sven Schüle
Hi all,

thank you for all of your replies :D . After correcting my perft function by not counting leaf nodes above MAX_DEPTH, I expect my perft numbers to be correct then (at least for the starting position, they are already correct with this change), I'll check it soon.

Hopefully there will be no reason for debugging my move generator in which I have much confidence and which did not show any legality problems within tournaments up to now. So it's probably only a matter of calculating perft numbers correctly.

Hi Reinhard,
Sven Sch?le wrote:Note that I mean the real perft number, not the total number of nodes visited.

Reinhard Scharnagl wrote:Perft counts all VALID moves within a ply. A VALID mating move still is a move. Thus not all pseudolegal mating moves will be counted, only the LEGAL will be.

of course you are right, but perhaps you have slightly misunderstood my question. Nevertheless - thank you for your hint!

Regards,
Sven

Re: perft question

PostPosted: 20 Jan 2005, 11:49
by Roman Hartmann
Sven Sch?le wrote:Hi,

[snip]

I have the impression that such nodes do not count but I want to be sure. I have implemented perft for Surprise now, but my numbers are slightly different, and it seems to be related to mate positions.

Cheers,
Sven


Hi,
I had the same problem. The easiest solution is to implement a function that gives you the numbers of child moves. Sharper is an engine with that feature implemented (my own engine roce has that too). Just google for sharper.

output of roce in the starting position:
Code: Select all
roce: divide 4

g1h3 8881
g1f3 9748
b1c3 9755
b1a3 8885
h2h3 8457
h2h4 9329
g2g3 9345
g2g4 9328
f2f3 8457
f2f4 8929
e2e3 13134
e2e4 13160
d2d3 11959
d2d4 12435
c2c3 9272
c2c4 9744
b2b3 9345
b2b4 9332
a2a3 8457
a2a4 9329

Moves: 20
Nodes: 197281
roce:


with that feature bugs are quite easy to spot. In my case some of the EP moves did cause some troubles.

Roman