Perft problems...

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27836
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Perft problems...

Post by hgm »

You could run it from a command-prompt window, and then copy-paste the output. (Rightclick the title bar, and select "edit -> select" (or mark?) from the menu. When you selected with the mouse, press "enter" to copy it to the clipboard.

That would be better than redirecting the output to a file, as I could also see the actual command line. (There might be something in the FEN it chokes on.)
Chris Tatham
Posts: 142
Joined: Wed Mar 08, 2006 8:15 pm

Re: Perft problems...

Post by Chris Tatham »

Code: Select all

C:\Chess\Sharper>perft 7 H20 -1 "7k/8/8/8/8/8/7P/4K2R w K - 0 1"
Hash-table size = fffff, Starts at 4a0020
 - - - - - - - - - - - -
 - - - - - - - - - - - -
 - - . . . . . . . k - -
 - - . . . . . . . . - -
 - - . . . . . . . . - -
 - - . . . . . . . . - -
 - - . . . . . . . . - -
 - - . . . . . . . . - -
 - - . . . . . . . P - -
 - - . . . . K . . R - -
 - - - - - - - - - - - -
 - - - - - - - - - - - -

Quick Perft by H.G. Muller
Perft mode: Hash-table size = 16MB, bulk counting in horizon nodes

perft(1)=10 ( 0.000 sec)

perft(2)=28 ( 0.000 sec)

perft(3)=382 ( 0.000 sec)

perft(4)=2019 ( 0.000 sec)

perft(5)=33154 ( 0.000 sec)

perft(6)=168175 ( 0.015 sec)

perft(7)=3049317 ( 0.000 sec)
User avatar
hgm
Posts: 27836
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Perft problems...

Post by hgm »

OK, you are using hash, so at least there could be an explanation for the difference. Apparently there is a hash collision.

I will check out if we are just extremely unlucky here, (I use 32-bit signatures in the hash) or if there really is an error in the hash-key caculation that enhances the probability for collision.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Perft problems...

Post by sje »

hgm wrote:I will check out if we are just extremely unlucky here, (I use 32-bit signatures in the hash) or if there really is an error in the hash-key caculation that enhances the probability for collision.
If you are using only a 32 bit signature, it doesn't take too much bad luck to have a false positive match.
[D]7k/8/8/8/8/8/7P/4K2R w K - 0 1

Code: Select all

[] emp 1
Kd1 1
Kd2 1
Ke2 1
Kf1 1
Kf2 1
O-O 1
Rf1 1
Rg1 1
h3 1
h4 1
Pathway count to depth one: 10
[] emp 2
Kd1 3
Kd2 3
Ke2 3
Kf1 3
Kf2 3
O-O 3
Rf1 3
Rg1 1
h3 3
h4 3
Pathway count to depth two: 28
[] emp 3
Kd1 30
Kd2 51
Ke2 51
Kf1 24
Kf2 51
O-O 51
Rf1 45
Rg1 16
h3 30
h4 33
Pathway count to depth three: 382
[] emp 4
Kd1 169
Kd2 295
Ke2 295
Kf1 138
Kf2 300
O-O 243
Rf1 196
Rg1 39
h3 164
h4 180
Pathway count to depth four: 2,019
[] emp 5
Kd1 2,369
Kd2 5,280
Ke2 5,231
Kf1 1,608
Kf2 5,208
O-O 4,421
Rf1 3,485
Rg1 655
h3 2,275
h4 2,645
Pathway count to depth five: 33,177
[] emp 6
Kd1 11,954
Kd2 27,747
Ke2 27,731
Kf1 8,528
Kf2 27,926
O-O 20,599
Rf1 14,660
Rg1 1,808
h3 11,567
h4 12,921
Pathway count to depth six: 165,441
[] emp 7
Kd1 201,144
Kd2 537,381
Ke2 535,628
Kf1 133,292
Kf2 539,503
O-O 392,254
Rf1 282,164
Rg1 31,108
h3 187,316
h4 217,145
Pathway count to depth seven: 3,056,935
[] emp 8
Kd1 1,114,637
Kd2 3,046,370
Ke2 3,053,499
Kf1 777,972
Kf2 3,091,239
O-O 2,028,134
Rf1 1,353,583
Rg1 140,206
h3 1,035,684
h4 1,162,797
Pathway count to depth eight: 16,804,121
[] emp 9
Kd1 20,789,962
Kd2 61,672,992
Ke2 61,925,945
Kf1 14,140,645
Kf2 62,605,263
O-O 39,386,470
Rf1 26,848,610
Rg1 2,580,370
h3 18,612,243
h4 21,233,665
Pathway count to depth nine: 329,796,165
[] emp 10
Kd1 114,791,034
Kd2 344,095,802
Ke2 346,499,635
Kf1 80,804,478
Kf2 350,063,238
O-O 207,212,339
Rf1 134,800,568
Rg1 12,543,192
h3 102,588,895
h4 113,634,317
Pathway count to depth ten: 1,807,033,498
[] emp 11
Kd1 2,261,866,373
Kd2 7,118,634,444
Ke2 7,177,817,555
Kf1 1,578,045,949
Kf2 7,218,340,881
O-O 4,074,069,858
Rf1 2,724,168,251
Rg1 243,048,430
h3 1,946,733,090
h4 2,168,415,984
Pathway count to depth eleven: 36,511,140,815
[] emp 12
Kd1 12,721,919,488
Kd2 40,134,642,161
Ke2 40,479,401,478
Kf1 9,049,373,035
Kf2 40,606,228,211
O-O 22,072,185,492
Rf1 14,362,476,144
Rg1 1,299,962,956
h3 10,897,117,246
h4 11,860,352,347
Pathway count to depth twelve: 203,483,658,558
[] emp 13
Kd1 257,618,956,835
Kd2 837,720,473,551
Ke2 845,400,950,183
Kf1 182,324,682,613
Kf2 842,157,254,200
O-O 437,737,937,231
Rf1 293,696,208,929
Rg1 26,056,669,093
h3 213,053,993,010
h4 232,109,951,310
Pathway count to depth thirteen: 4,167,877,076,955
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: Perft problems...

Post by ilari »

Chris Tatham wrote:Thanks Ilari, I did try this and no all are wrong, too many in each case.

Code: Select all

perft?? 6
98-87  94410 nodes
98-88  60326 nodes
98-97  62736 nodes
Total moves at root = 3
Total node count = 217472
Time = 0.4716797s
Average nodes/sec = 461058
but perft(5) after making any of these 3 moves is correct :roll:
When that happens, it's often a bug in the "undo move" routine. Are you restoring the previous position entirely with castling rights and enpassant square?
User avatar
hgm
Posts: 27836
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Perft problems...

Post by hgm »

sje wrote:If you are using only a 32 bit signature, it doesn't take too much bad luck to have a false positive match.
Well, one in 4 billion per probe. Note that the end leaves are not hashed, so the number of hash probes for a perft(7) would be given by perft(6).

But we get a wrong perft(5), meaning that one of the perft(4)=2019 probes should have been a collission. The probability on that should be 2019 in 4e9, or 1 in 2 million. I do consider something happening with odds like that pretty bad luck. The risk I take when I cross the street is far bigger...