Answers.Body: <p>Assuming you mean pieces of just one color, 15 can be attacking one square:</p>
  <pre><code>[fen &quot;B3R3/7Q/3N1N2/2N3N1/3Kn3/2NP1PN1/3N1N2/4R3 w - - 0 1&quot;]
  </code></pre>
  <p>The wrong-colored bishop is the only one that can't participate.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-28T23:33:00.293Z
Answers.Text: If it matters, those pawns could also have promoted to bishops. Just in case you don't count pawns as "pieces" for your purposes.
Answers.UserDisplayName: D M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-28T23:31:32.930Z
Answers.LastActivityDate: 2024-02-28T23:31:32.930Z
Answers.UserDisplayName: D M
Body: <p>I'm thinking about developing an optimized chess database file format. I can record a single move in 12 bits: two squares, each one with two coordinates, where each one is a number from 1 to 8.</p>
  <p>Algebraic notation only shows the destination square for a move and the piece's type (either blank for pawn or a letter for one of the five non-pawns), which is also 12 bits; but when two pieces of the same type can move to the same square, they're disambiguated by which file the piece was on before, which is another 8 options or 3 bits. (Castling could be encoded as a king move of two squares' distance, rather than being a special case like SAN does it.)</p>
  <p>My idea was to encode the move with just the destination square, and when there's ambiguity, select which one of the pieces it can be by enumerating them in some standard order then indicating which one it is with some index.</p>
  <p>How big should the space for this index be? What's the largest number of squares on which there can be pieces that all attack a particular square, and what's an example of such a position (so I can use it for testing)?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-28T23:27:02.543Z
Comments.Text: Pieces of just one color, or both?
Comments.UserDisplayName: D M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-29T06:10:30.360Z
Comments.Text: @DM Single color, because that's the only thing that matters for the question of determining that color's next move.
Comments.UserDisplayName: Danya02
Tags: <computer-chess><database><attack>
Title: What's the maximum number of pieces attacking a single square?
ThreadText: # What's the maximum number of pieces attacking a single square?
  
  (Asked by: username_0 on 2024-02-28)
  
  I'm thinking about developing an optimized chess database file format. I can record a single move in 12 bits: two squares, each one with two coordinates, where each one is a number from 1 to 8.
  
  Algebraic notation only shows the destination square for a move and the piece's type (either blank for pawn or a letter for one of the five non-pawns), which is also 12 bits; but when two pieces of the same type can move to the same square, they're disambiguated by which file the piece was on before, which is another 8 options or 3 bits. (Castling could be encoded as a king move of two squares' distance, rather than being a special case like SAN does it.)
  
  My idea was to encode the move with just the destination square, and when there's ambiguity, select which one of the pieces it can be by enumerating them in some standard order then indicating which one it is with some index.
  
  How big should the space for this index be? What's the largest number of squares on which there can be pieces that all attack a particular square, and what's an example of such a position (so I can use it for testing)?
  
  **Tags:** computer-chess, database, attack
  
  > **Comments:**
  > **username_1**: Pieces of just one color, or both?  
  > **username_0**: @DM Single color, because that's the only thing that matters for the question of determining that color's next move.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-28. Score: 3 | Accepted answer
  
  Assuming you mean pieces of just one color, 15 can be attacking one square:
  
  ```
  [fen "B3R3/7Q/3N1N2/2N3N1/3Kn3/2NP1PN1/3N1N2/4R3 w - - 0 1"]
  
  ```
  
  The wrong-colored bishop is the only one that can't participate.
  
  > **Comments:**
  > **username_1**: If it matters, those pawns could also have promoted to bishops. Just in case you don't count pawns as "pieces" for your purposes.  
  
  ---
  
  