Main, Download, History, ELO calculation, Perft

Perft calculation

To verify that a chess program correctly understands all the rules in which the pieces are allowed to move a simple test is to calculate perft values from certain positions. The perft value is calculated for a specific position to a specific depth. For the initial position the perft value to depth 1 "perft(1)" is 20 as there are 20 valid moves from the current position. Since each of the 20 positions allows the opponent to pick any move of 20 the perft(2) value is 400.

Note that perft values for depths larger than 5 can take a considerable time to calculate and I strongly recommend you to calculate them one after the other so that you get a feel for how long it takes, before trying to calculate perft(9) for the initial position.

If you are using perft calculation for debugging a chess engine (which is quite likely) there is a trick you might want to use. When calculating for example perft(5) and finding that your value differs from my value you want to know why, so you can fix it. By implementing a command that generates all possible positions from the current position and then calculate the perft value with depth - 1 for the positions you'll quickly find what causes the problem. For more info on this try out the "divide" command in Sharper.

Values that I have calculated and verified with other engines:

Initial position rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
depthperft value
120
2400
38902
4197281
54865609
6119060324
73195901860
884998978956
92439530234167
1069352859712417


Position r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
This position is very good because it catches many possible bugs.
depthperft value
148
22039
397862
44085603
5193690690
68031647685


More positions that I've found useful for finding bugs

Position 8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - 1 67
Perft(1) = 50
Perft(2) = 279

Position 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28
Perft(6) = 38633283

Position rnbqkb1r/ppppp1pp/7n/4Pp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3
Perft(5) = 11139762

Position 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -
Perft(6) = 11030083
Perft(7) = 178633661