However in testing my castling code (using Sharper as the benchmark) I keep finding problems with the following simple position:
[D]7k/8/8/8/8/8/7P/4K2R w K - 0 1
Here at 7ply Sharper has:
Code: Select all
e1f2 539503
e1d2 537381
e1e2 535628
e1f1 133292
e1d1 201144
e1g1 392254
h1g1 31108
h1f1 282164
h2h3 187316
h2h4 217145
Nodes: 3056935
Moves: 10
Code: Select all
perft?? 7
25-36 539503 nodes
25-34 537381 nodes
25-24 201144 nodes
25-26 133292 nodes
25-35 535628 nodes
25-27 392254 nodes
28-27 31108 nodes
28-26 282164 nodes
38-58 217752 nodes
38-48 187845 nodes
Total moves at root = 10
Total node count = 3058071
Time = 6.547852s
Average nodes/sec = 467034
There must be something wrong with my castling code as perft works (v Sharper) in the same position with no castling rights and interestingly also works with castling rights but without the h2 pawn. Yet it fails with a white pawn seemingly anywhere on the second or third rank.
I'm assuming that there must be illegal O-O's in the last ply (I have 1291 O-O at 7 ply - is someone able to confirm the true figure for me?). I was initially labouring under the assumption it might be the rook returning to h1 and then castling (eg h4, Rh3, Rh1 and O-O) but then this error should perhaps manifest itself at an earlier depth (eg Rg1, Rh1 and O-O) (ie 5 ply) and it works with no h2 pawn anyway.
After much effort I still can't see or find the problem but would much appreciate any comparable figures or suggestions from more experienced programmers if I'm missing something glaringly obvious (likely!)
Many thanks for any help.