If you are lost in debugging a move generator with perft, an obvious but useful "trick" that is already used widely for chess is to breakdown perft(d) per move. Suppose you are writing a new 8x8 checkers engine, and you compare perft(d) for various d against the numbers generated by a trusted other engine:
Code: Select all
d=1 : 7
d=2 : 49
d=3 : 302
d=4 : 1469
d=5 : 7361
d=6 : 36768
d=7 : 179740
d=8 : 845931
Now suppose your perft(d) scores are correct for 1<=d<=7 but are off for d=8. How to proceed without aimlessly staring at many positions? In this case, breakdown the perft scores of the trusted engine down per move, as in:
Code: Select all
breakdown perft(8):
12-16 : nodes=142459
11-16 : nodes=163687
11-15 : nodes=96625
10-15 : nodes=108364
10-14 : nodes=94412
9-14 : nodes=92267
9-13 : nodes=148117
total-nodes=845931
and compare those with the perft scores per move of the new engine. Then pick the move that is wrong (if the counts of several or all moves are off, just pick a faulty one abritrarily), apply it on the board, and compute perft(d-1) broken down per move. Unless you have a very nasty bug, one of those perft scores will be wrong and you proceed with applying that move and perft(d-2) etc. At one point, you have a perft(1) score that is off, and debugging the move generator is easy.
Simple, obvious, but hopefully a useful hint.