All Chess Positions Open the map

Chess by the numbers

What is perft?

Perft — short for performance test — counts every legal sequence of moves from a position down to a fixed depth. From the starting position the counts are 20, 400, 8,902 and 197,281 for one to four moves. Chess programmers compare their own counts with these to make sure their move generator has no bugs.

The table

The numbers below also say how many of the sequences end with a capture, an en passant capture, castling, a promotion, a check or a checkmate.

DepthGamesCapturesEn passantCastlesPromotionsChecksMates
120000000
2400000000
38,90234000120
4197,2811,5760004698
54,865,60982,7192580027,351347
6119,060,3242,812,0085,24800809,09910,828
73,195,901,860108,329,926319,617883,453033,103,848435,767
884,998,978,9563,523,740,1067,187,97723,605,2050968,981,5939,852,036
92,439,530,234,167125,208,536,153319,496,8271,784,356,00017,334,37636,095,901,903400,191,963

The firsts

Read down the columns and you find when each rule first comes into play: the first captures and checks at depth 3, the first checkmates at depth 4 (the eight versions of the Fool’s Mate), the first en passant capture at depth 5, the first castling at depth 7 and the first promotion at depth 9.

How it is computed

The idea fits in a few lines: generate every legal move, play it, count everything below it, take it back.

perft(depth):
  if depth = 0: return 1
  total = 0
  for each legal move:
    make the move
    total += perft(depth − 1)
    unmake the move
  return total

Because the count is exact, a single missing or extra move anywhere — a forgotten en passant, an illegal castling through check — changes the total. Programmers also test tricky positions full of castling rights, pins and promotions, the best known of which is nicknamed “Kiwipete”.

On this site

The map is perft drawn as a picture: around the position you are looking at, its rings hold the games of depth 1 to 4. The ladder in the side panel lists the counts up to depth 15 and counts depth 5 live in your browser.

Sources