Another Silly Question: How Many Chess Moves Are There?
Working on those knight moves.

Another Silly Question: How Many Chess Moves Are There?


Anyone who's played over-the-board knows how to read and write algebraic notation. While you're playing you probably don't have time to reflect on the notation (you've got other things to think about!) But one esoteric question you might ask is, "How many different moves is it possible to write down?"

Which, OK. That might not be something you'd ever want to know. But the answer to that question is surprisingly central to how neural-network engines work. For that reason it's worth writing, and hopefully reading, a short post about.

In standard algebraic notation one tries to be as brief as possible: If you don't need to specify a square of origin, you don't. Engine developers don't worry about this rule. They just write every move like "Ka1b1" (whereas a human would just write Kb1).

To figure out how many possible moves there are, we can add up all the pieces' moves individually. Luckily I did something similar to this in a previous post!

For a bishop:

Number of bishop moves from each square.

The number of legal bishop moves is just the sum of all the numbers above. You can either try adding them yourself, or you can trust me that there are 560 of them!

And what about the rest of the pieces? I'm glad you asked! I'll go through this quickly:

Piece Moves
Pawn 412
Knight 336
Bishop 560
Rook 896
Queen 1456
King 420
Castling 4
TOTAL 4164

So there are 4164 possible moves in a game of chess. 

...or are there?!

Humans specify which piece made a move (Ra3); engines also specify an origin (Ra1a3). But what if you ignored the piece altogether and just looked at the starting and ending square? The following move might be described as"Bg1", "Bc5g1", or "c5g1" (that it is a capture makes no difference):

If you know the position (or have been tracking moves from the beginning of the game), "c5e1" describes this move perfectly. There is only one piece on c5 (a bishop) so you don't have to specify which piece is moving from c5. It's a bishop.

Adding every piece move from every square won't necessarily answer our question of "How many chess moves are there?". Many are duplicates, like Qa1h8 and Ba1h8, which are both written a1h8. Therefore, using this type of origin-destination notation will give us a different number than above.

It turns out that we only need to add queen moves, knight moves, pawn promotions, and castling if we want to find this second number (can you figure out why?):

Piece Moves
Pawn 176
Knight 336
Queen 1456
Castling 4
Total 1972

That's right: There are 1972 possible moves in a game of chess. (Hooray!)

If you want to know "How many moves can I make", that answer is 1882 (the number of possible moves, minus your opponent's pawn promotions, minus your opponent's castles).

I see no reason why anyone would have read this far. But, if you're still here, thanks!

It turns out that these numbers are integral to making a neural-network engine. Your network should be designed to accept chess positions as inputs, and then output 1882 values- each corresponding to one of chess' possible moves. In fact, having this number of outputs is what makes a network useful for chess rather than Go or Shogi or Starcraft. (Depending on the code, it doesn't have to be exactly 1882, but I'll cover that in a future post).

I should stop now. Let me know what you think in the comments!