2

Starting from the standard initial position, how many possible legal chess moves are there in this and all possible following positions?

Say, ignoring the starting position, a bishop can move to 32 squares (but the other covers the other 32), a rook to 64, if both sides are taken into account, pawns can also reach all 64 squares, a knight, king and queen can also reach all 64 positions.

So in sum, that should be 384 total move target-square+piece combinations. Is this correct?

But what is the number of moves if the starting position is not ignored?

Then, 16 pawn double-step advances have to be added, plus 4 castling moves (2, queen and kingside for each player). And en passant , which should be 7 left and 7 right, times 2 for both players. And all possible source-target square combinations of all other pieces!

7
  • 2
    Nit pick: The notation doesn't matter - the move stays the same irrespective of how it is recorded - Ceci n'est pas un chess move: 1 e4. Do you mean the sightly different question which is something like "given a chess notation system what is the number of different, legal recordings of moves"? And sorry for the very poor phrasing! – Ian Bush Dec 13 '20 at 9:34
  • What do you mean by "but unreachable positions", is there a word missing? – Ian Bush Dec 13 '20 at 9:34
  • You are right, the notation doesn't matter (although this is also an interesting question!), I've edited my question. Re. unreachable I meant something along this: chess.stackexchange.com/questions/4830/… but now I'm confused myself and will omit it ^^ – 2080 Dec 13 '20 at 9:42
  • 1
    Your question is very confusing. You are counting moves, then counting reachable squares, then mixing in moves again - if you are first interested only in whether a white or black pawn can reach field e4, why suddenly double-count e4 as reachable from e2 as well as e3 (and also from e5!). Later you mention en passant but do not mention capturing pawns before that. It is very unclear what you want to count – Hagen von Eitzen Dec 13 '20 at 10:02
  • 2
    Could you please define what you mean by distinct, countable moves? If a white pawn makes the capture c5xd6 does it matter what piece or pawn was captured and does it matter which square the captured pawn or piece was on? For instance for a pawn capture, does it matter if the captured pawn was on d6 (normal capture) or on d5 (en passant)? I would suggest that when considering white moves two moves are only different if the position of the white pieces before and after are different, i.e. c5xd6 is the same move regardless of the piece captured or the square it was on. – Brian Towers Dec 13 '20 at 11:39
3

The white king can move to 8 fields from the inner 36 fields, to 4 fields from the 4 corner fields and to 5 fields from the remaining 24 boundary fields. That's 420 moves for the white king, add 2 for castlings to arrive at 422. If you distinguish captures, this almost doubles (castling can't capture) to 842. Now allow for the black king to double this (1684)? Or identify moves they could both make (i.e., all but castling - 844)?

A rook can always (given free line of sight) move to 14 squares. That's 896 moves. Double to 1792 if you distinguish captures. Double again (3584) if you want to distinguish colour.

On a diagonal (NW to SE, say) of length n, a bishop can make n(n-1) moves (pick a start field and a distinct end field). Sum over n=1,2,3,4,5,6,7,8,7,6,5,4,3,2,1 (i.e., ignoring the colour of the bishop) to arrive at 280 moves, double to 560 to count both diagonal directions. Double (1120) if you want to distinguish captures, double once more (2240) if you want to distinguish by colour.

For the queen simply add rook and bishop, thus counting 1456, 2912, or 5824 moves.

The knight can typically make 8 moves, but as with the king we have to account for nearby boundary. It is easier to count by direction: There are 42 (6 by 7) fields from where we can go two to the right and one up, say. We have the same number 42 (though with different fields) for all eight directions, hence a total of 336 knight moves. Double (672) if you distinguish captures. Double again (1344) if you distinguish by colour.

A white pawn can move two fields ahead from its initial position (8 moves). It can move one ahead from rows 2 to 6 (40 moves). It can move ahead from row 7 and promote to queen, rook, bishop, or knight (32 moves). For pawns, we must distinguish captures: In only seven of the eight columns, we can capture to the right, and in seven of eight columns we can capture to the left. This gives us 70 capture moves from rows 2 to 6, plus 56 capture with promotion. So far 206. If you want to distinguish capture en passant from a normal capture by the same movement (start and end field) of the pawn, add 14 to arrive at 220. Again, at least for pawns it seems useful to distinguish by player and arrive at 440.

In summary, the most generous way of counting possible moves might lead to 1684 + 3584 + 2240 + 5824 + 1344 + 440 = 15116 distinct moves. One could raise the number even higher by distinguishing moves that give check or even checkmate, or by distinguishing captures according to the piece captured.

1
  • 4
    "The White king can move... to 4 fields from the 4 corner fields " - Shouldn't that be 3? – D M Dec 13 '20 at 16:01
2

If the board is given and only the source and target square, as well the promotion choice are considered (as in the UCI format), then it appears there will be 1968 possible moves.

# Python
# pip install python-chess
import chess

moves = 0

# Queen, covers all lines and diagonals
for x in range(8):
    for y in range(8):
        board = chess.Board("8/8/8/8/8/8/8/8")
        board.set_piece_at(chess.square(x,y), chess.Piece(chess.QUEEN, chess.WHITE))
        moves += len(list(board.generate_legal_moves()))
        
# Knight jumps
for x in range(8):
    for y in range(8):
        board = chess.Board("8/8/8/8/8/8/8/8")
        board.set_piece_at(chess.square(x,y), chess.Piece(chess.KNIGHT, chess.WHITE))
        moves += len(list(board.generate_legal_moves()))
        
        
# Straight pawn promotions, 2 players, 8 ranks each, 4 choices (queen, rook, bishop, knight)
moves += 2*8*4

# Diagonal pawn promotions, when capturing a piece
# 2 players, 14 diagonals (12 in the center and 1 each in the first and last ranks), 4 choices
moves += 2*14*4
        
print(moves)

Castling is assumed to be indicated by moving the king two steps.

Here are all possible UCI strings and here is the code to generate them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.