Answers.Body: <p>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)?</p>
  <p>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.</p>
  <p>On a diagonal (NW to SE, say) of length <em>n</em>, a bishop can make <em>n</em>(<em>n</em>-1) moves (pick a start field and a distinct end field). Sum over <em>n</em>=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.</p>
  <p>For the queen simply add rook and bishop, thus counting 1456, 2912, or 5824 moves.</p>
  <p>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.</p>
  <p>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 <em>must</em> 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.</p>
  <p>In summary, the most generous way of counting possible moves might lead to 1684  + 3584 + 2240 + 5824 + 1344 + 440 = <strong>15116</strong> 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-13T16:01:41.487Z
Answers.Text: "The White king can move... to 4 fields from the 4 corner fields " - Shouldn't that be 3?
Answers.UserDisplayName: D M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-13T12:03:02.987Z
Answers.LastActivityDate: 2020-12-13T12:03:02.987Z
Answers.UserDisplayName: Hagen von Eitzen
Answers.Body: <p>If the board is given and only the source and target square, as well the promotion choice are considered (as in the <a href="https://en.wikipedia.org/wiki/Universal_Chess_Interface" rel="nofollow noreferrer">UCI</a> format), then it appears there will be 1968 possible moves.</p>
  <pre><code># 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(&quot;8/8/8/8/8/8/8/8&quot;)
          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(&quot;8/8/8/8/8/8/8/8&quot;)
          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)
  </code></pre>
  <p>Castling is assumed to be indicated by moving the king two steps.</p>
  <p><a href="https://gist.github.com/void4/11b1623128c9a97ff461eef81edae665" rel="nofollow noreferrer">Here</a> are all possible UCI strings and <a href="https://gist.github.com/void4/77e1f0aa21ad40622c5634ba03261383" rel="nofollow noreferrer">here</a> is the code to generate them.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-11T22:06:19.960Z
Answers.LastActivityDate: 2021-01-12T13:34:04.220Z
Answers.LastEditDate: 2021-01-12T13:34:04.220Z
Answers.UserDisplayName: 2080
Body: <p>Starting from the standard initial position, how many possible legal chess moves are there in this and all possible following positions?</p>
  <p>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 <a href="https://en.wikipedia.org/wiki/Knight%27s_tour" rel="nofollow noreferrer">knight</a>, king and queen can also reach all 64 positions.</p>
  <p>So in sum, that should be 384 total move target-square+piece combinations. Is this correct?</p>
  <p>But what is the number of moves if the starting position is not ignored?</p>
  <p>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!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T09:34:17.333Z
Comments.Text: 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!
Comments.UserDisplayName: Ian Bush
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T09:34:41.497Z
Comments.Text: What do you mean by "but unreachable positions", is there a word missing?
Comments.UserDisplayName: Ian Bush
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T09:42:22.670Z
Comments.Text: 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: https://chess.stackexchange.com/questions/4830/how-many-legal-but-unreachable-positions-exist but now I'm confused myself and will omit it ^^
Comments.UserDisplayName: 2080
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T10:02:13.390Z
Comments.Text: 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
Comments.UserDisplayName: Hagen von Eitzen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T10:04:14.143Z
Comments.Text: @HagenvonEitzen Very true, I just updated to make the "consider the source square or not" distinction. I'm a bit confused, too ^^
Comments.UserDisplayName: 2080
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T11:39:12.827Z
Comments.Text: 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.
Comments.UserDisplayName: Brian Towers
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T12:06:25.217Z
Comments.Text: @BrianTowers Both choices are interesting!
Comments.UserDisplayName: 2080
Tags: <analysis><mathematics><calculation>
Title: How many possible chess moves are there?
ThreadText: # How many possible chess moves are there?
  
  (Asked by: username_0 on 2020-12-13)
  
  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](https://en.wikipedia.org/wiki/Knight%27s_tour), 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!
  
  **Tags:** analysis, mathematics, calculation
  
  > **Comments:**
  > **username_1**: 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!  
  > **username_1**: What do you mean by "but unreachable positions", is there a word missing?  
  > **username_0**: 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: https://chess.stackexchange.com/questions/4830/how-many-legal-but-unreachable-positions-exist but now I'm confused myself and will omit it ^^  
  > **username_2**: 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  
  > **username_0**: @HagenvonEitzen Very true, I just updated to make the "consider the source square or not" distinction. I'm a bit confused, too ^^  
  > **username_3**: 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.  
  > **username_0**: @BrianTowers Both choices are interesting!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-12-13. Score: 4
  
  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.
  
  > **Comments:**
  > **username_4**: "The White king can move... to 4 fields from the 4 corner fields " - Shouldn't that be 3?  
  
  ---
  
  ### Answer by username_0 on 2021-01-11. Score: 3
  
  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.
  
  
  ---
  
  