Perft

Perft is a program that counts legal chess moves in a chess position. By comparing counts for various positions against other known working programs, you can determine if your program is working or not.

Here are some positions :

Position 0


Depth Count
1 20
2 400
3 8,902
4 197,281
5 4,865,609
6 119,060,324
7 3,195,901,860
8 84,998,978,956*
9 2,439,530,234,167*
* = not directly verified.
Numbers obtained from Peter McKenzie's Perft page
  Position 1


Depth Count
1 48
2 2039
3 97,862
4 4,085,603
5 193,690,690
6 8,031,647,685

Position obtained from Peter McKenzie's Perft page
 
Position 2


Depth Count
1 18
2 290
3 5,044
4 89,363
5 1,745,545
6 34,336,777
7 749,660,761

Position obtained from Peter McKenzie's Perft page
  Position 3


Depth Count
1 14
2 191
3 2,812
4 43,238
5 674,624
6 11,030,083
7 178,633,661

Position obtained from Peter McKenzie's Perft page
 
Position 4


Depth Count
1 38
2 984
3 38,452
4 1,032,199
5 40,746,322
  Position 5


Depth Count
1 44
2 1,553
3 68,831
4 2,515,226
5 111,397,834
6 4,176,909,424
Position 6


Depth Count
1 36
2 1,894
3 71,531
4 3,614,225
5 140,939,364
6 6,921,534,698

Stein, Hort -- Los Angeles, 1968 (Stein played Nxe5)

Perft is a bare-bones implementation. Data entry choices are *not* edited or validated .... enhancements are welcome (of course). Instructions for Perft are given below.

When you first execute Perft, you are presented with the following :
0. rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
1. r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
2. 8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1
3. 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1
4. r1bqk1nr/ppppbp1p/2n1p3/2P1P3/3P2p1/2N5/PP3PPP/RNBQKB1R w KQkq - 0 3
5. r3k2r/pp1bq1pp/2n2b2/P1p1B3/5p2/1BP2N1P/5PP1/R2Q1RK1 w kq - 0 2
6. r3r1k1/2qn3p/2n2bp1/NpPbpp2/1P1p4/3P1NP1/1B3PBP/2RQR1K1 w - - 0 1

Which position ?
At this point you can either enter a number for a known position or enter a FULL FEN position.

If you enter a number, the following dialog is presented :
Which position ? 1
What Depth (max : 6) ? 4
Moves per Second (344,367) ? 200000
Ouput filename ( means None) ?
This dialog means
  • position 1 was selected
  • calculate to a depth of 4 ply (not moves).
  • You are guessing that the program can calculate 200,000 Moves per Second. This is used when calculating the approximate end time.
  • Nothing was entered at the last prompt. If a filename is entered here, all of the calculated moves are output to this file.
After Perft is done running you are presented with information related to the number of moves calculated and how long the calculation took. A sample appears below :
Perft for depth     : 4
Known MoveCount     : 4,085,603
Generated MoveCount : 4,085,603
Approx Elapsed Time : 00:00:20.4280000
Actual Elapsed Time : 00:00:20.6718750
Actual Start Time   : 10/30/2003 8:45:30 PM
Actual End Time     : 10/30/2003 8:45:51 PM
Estimated Moves/Sec : 200,000
Actual Moves/Sec    : 197640.659108088


0. rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
1. r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
2. 8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1
3. 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1
4. r1bqk1nr/ppppbp1p/2n1p3/2P1P3/3P2p1/2N5/PP3PPP/RNBQKB1R w KQkq - 0 3
5. r3k2r/pp1bq1pp/2n2b2/P1p1B3/5p2/1BP2N1P/5PP1/R2Q1RK1 w kq - 0 2
6. r3r1k1/2qn3p/2n2bp1/NpPbpp2/1P1p4/3P1NP1/1B3PBP/2RQR1K1 w - - 0 1

Which position ? r2qkbnr/pp1npppp/2p3b1/8/3P4/5NN1/PPP2PPP/R1BQKB1R w KQkq - 0 7
IF you enter a FEN position, the following dialog is presented :
What Depth ? 4
What is the known Move Count (0) ?
Moves per Second (344,367) ?
Ouput filename ( means None) ?
The only real difference dialog difference is the 'known Move Count" prompt. If the known move is entered, it is used to aprroximate the end time.