Answers.Body: <p>It's :<br>
  numberOfPawnsPieces(=17) * numberOfRooksPieces(=5) * numberOfBishopsPieces(=5) * numberOfKnightsPieces(=5) * numberOfQueensPieces(=3) * numberOfKingsPieces(=1)<br>
  = 6375 </p>
  
  <p>I added one to each number of same piece in case there is no one of its kind(for queens for example, there may be two queens, one queen, or none), except for Kings where there always must be 2 kings on the board, so the number of combinations for kings number is only 1.  </p>
  
  <p>**</p>
  
  <p><strong>EDIT : In cas there is promotions of pawns</strong></p>
  
  <p>**<br>
  My idea to tackle this is to separate all possible cases, i.e. when there is promotion of 1 pawn, promotion of 2 pawns,...,promotion of 8 pawns. ( 8 pawns is the maximum number of possible promotions )<br>
  Generally speaking, when <code>x</code> pawns are promoted, we will proceed same as above, but the number of pawns will be in each case (16-x), plus an other group of <code>4 * x</code> possibly created pieces. Finally we will sum all over the cases :</p>
  
  <pre><code>                17*5*5*5*3*1 + SUM[x=1--&gt;16,(16-x+1)*5*5*5*3*(4*x)] = **1 230 375**
  </code></pre>
  
  <p>This is approximate, I may have forgotten some cases, or added some positions that are just impossible to happen in a chess game,...etc.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-27T12:38:20.560Z
Answers.Text: This is the correct number if you don't include pawn promotion.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T14:20:15.570Z
Answers.Text: @DagOskarMadsen would you please check my edit for the answer ?
Answers.UserDisplayName: mounaim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T14:21:24.217Z
Answers.Text: @Adam Speight check my edit for the answer :)
Answers.UserDisplayName: mounaim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T14:26:57.630Z
Answers.Text: Actually there can be 16 promotions: http://chess.stackexchange.com/questions/4128/shortest-game-with-18-queens, but in a legal game then some of the other pieces must have bee captured on the way. If you only consider legal games, then this becomes a very hard chess question rather than a mathematical question.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T14:48:10.977Z
Answers.Text: Thanks @DagOskarMadsen for this beautiful game with 16 queens, I thought this was just impossible !
Answers.UserDisplayName: mounaim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T15:15:17.743Z
Answers.Text: Your answer now is much too large since you are counting the same piece distributions many times. Your answer would have been correct if promoted pieces were to be considered different from the starting pieces. For instance you are counting two kings and a queen as different from two kings and a promoted queen.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-28T15:55:44.080Z
Answers.Text: you're right @DagOskarMadsen, my answer may involve duplicated endgames, I will try to work on this :)
Answers.UserDisplayName: mounaim
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-27T11:03:23.910Z
Answers.LastActivityDate: 2014-01-28T14:46:26.237Z
Answers.LastEditDate: 2014-01-28T14:46:26.237Z
Answers.UserDisplayName: mounaim
Answers.Body: <p>Initialy I posted that only 8 promotions for both sides are posible because pawns are oposed in the same file and to promote one have to be taken.</p>
  
  <p>Edited:</p>
  
  <p>I think that for each promotion one pawn or a piece shoud be taken. Because pawns are in front of each other ,blacks and whites ,to promote one of both have to move to the side(take another piece or pawn) or be taken. then I recalculated the final result to <strong>80094</strong> diferent legal piece combinations. I created this script to show all (i modified thanks to the comments of lodebari)</p>
  
  <pre><code>(function (pieceset) {
      'use strict';
      var n = 0,
          cc = function cc(arr) {
              var temparr=arr.slice(0);
              while (temparr[0]&gt;=0) {
                  while (temparr[1]&gt;=0) {
                      while (temparr[2]&gt;=0) {
                          while (temparr[3]&gt;=0) {
                              while (temparr[4]&gt;=0) {
                                  var maxp = 0;
                                  var nump = temparr[1]+temparr[2]+temparr[3]+temparr[4]; 
                                  if (temparr[1]&gt;4) maxp+=(temparr[1]-4);
                                  if (temparr[2]&gt;4) maxp+=(temparr[2]-4);
                                  if (temparr[3]&gt;4) maxp+=(temparr[3]-4);
                                  if (temparr[4]&gt;2) maxp+=(temparr[4]-2);
                                  nump = nump - maxp;
                                  if ((maxp+temparr[0]&lt;=16)&amp;&amp;((nump+temparr[0]+(maxp*2))&lt;=30)) {
                                      n++;
                                      console.log(n,"-&gt;",temparr);
                                  }
                                  temparr[4]=temparr[4]-1;
                              }
                              temparr[4]=arr[4];
                              temparr[3]=temparr[3]-1;
                          }
                          temparr[3]=arr[3];
                          temparr[2]=temparr[2]-1;
                      }
                      temparr[2]=arr[2];
                      temparr[1]=temparr[1]-1;
                  }
                  temparr[1]=arr[1];
                  temparr[0]=temparr[0]-1;
              }
              return 0;
          };
      cc(pieceset);
  }([16,20,20,20,18,2]));
  </code></pre>
  
  <p>When you run it it print lines like this:</p>
  
  <pre><code>1 '-&gt;' [ 16, 4, 4, 4, 2, 2 ]
  </code></pre>
  
  <p>the fist number its the combination number followed by Pawns,Rooks,Knights,Bishops,Queens,Kings. The fist line corresponds the fist position with full board, and the last with the two kings alone.</p>
  
  <p>You can try here : <a href="https://repl.it/xlO/4" rel="nofollow">https://repl.it/xlO/4</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-15T06:02:47.813Z
Answers.Text: Actually, for a pawn to able to promote it is necessary that the pawn in front moves aside (taking a piece or another pawn) or is taken.
Answers.UserDisplayName: lodebari
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-15T02:56:51.847Z
Answers.LastActivityDate: 2015-10-15T20:03:29.863Z
Answers.LastEditDate: 2015-10-15T20:03:29.863Z
Answers.UserDisplayName: girarvi
Answers.Body: <p>I know that the upper limit can not be greater than <strong>2304000</strong>
  Which is the answer to the following</p>
  
  <pre><code>16 (Pawns) * 20 (Rooks) * 20 (Knights) * 20 (Bishops) * 18 (Queens)
  </code></pre>
  
  <p>But not all of those are possible, so doing a quick programming</p>
  
  <pre><code> c:= 0
   p:= 0 .. 16
   r:= 0 .. 20
   b:= 0 .. 20
   n:= 0 .. 20
   q:= 0 .. 18
   if Sum( p, r, b, n, q, 2) &lt;= 32 then c+=1
  </code></pre>
  
  <p>Calculates <strong>c</strong> to be <strong>305090</strong> combinations. (2<sup>18</sup> &lt; c &lt; 2<sup>19</sup>)</p>
  
  <p>If I just focus on end games (no pawns) I calculate <strong>c</strong> to be <strong>3060</strong>  2<sup>11</sup> &lt; c &lt; 2<sup>12</sup></p>
  
  <p>Is my algorithm producing the correct results?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-26T17:32:56.543Z
Answers.Text: Impossible. Some of those pawns have to take other things to clear the way for them to be promoted or they need to be taken for promotions to happen.
Answers.UserDisplayName: yobamamama
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T02:54:52.033Z
Answers.Text: There are some other restrictions. If there are 20 rooks, then there cannot be more than 4 knights, for instance.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T02:59:00.503Z
Answers.Text: @DagOskarMadsen Good point, which suggest the value is lower than these upper bounds.
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T03:14:42.800Z
Answers.Text: Adding the constraint __Sum(r,n,b,a)<= (20-p)__ reduces the combinations to **53068** and **3060**
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T09:16:46.360Z
Answers.Text: The question now says "...all theoretically possible games played from the initial position ....". If you have a large number of promotions, then there must have been several captures on the way. It is going to be very hard to calculate the exact answer, maybe an upper bound is the most we can hope for.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T09:21:52.087Z
Answers.Text: I think the constraint should be Sum(r,n,b,q)<= (30-p)
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T15:36:25.963Z
Answers.Text: No, it's more subtle than in my previous comment. The constraint is max(r,4)+max(n,4)+max(b,4)+max(q,2)<=(30-p)
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T17:36:00.173Z
Answers.Text: @DagOskarMadsen I suspect that constraint will produce the wrong value. Then can be less than 4 rooks on the board.
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T17:43:45.250Z
Answers.Text: Sure. There are 16 pawns that can promote, so from promotions we get max(r-4,0)+max(n-4,0)+max(b-4,0)+max(q-2,0)<=(16-p). This is equivalent to what I wrote. Trust me, I am a mathematician :)
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T17:53:06.847Z
Answers.Text: @DagOskarMadsen I ain't. So could you explain (like I am 5) how you came that expression.eg  max(q-2,0)? It's possible to have all the 16 pawns promoted to queens and still have the original 2 queen also. Which is 18 queens.  Me Confused. :-(
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T17:57:51.257Z
Answers.Text: If you have 18 queens, then 16 of them must have been promoted. max(q-2,0)=max(16,0)=16. Similarly, max(r-4,0) counts the number of rooks that *must* have been promoted. For instance if there are 6 rooks, then at least max(r-4,0)=max(2,0)=2 of them must have been promoted.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T18:01:50.153Z
Answers.Text: The formula then counts on the number of pieces on the board that *must* be promoted pieces and compares with the number of missing pawns.
Answers.UserDisplayName: Dag Oskar Madsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T19:29:30.767Z
Answers.Text: So I calculate the answers to be **164603** and **32275** (end game). @DagOskarMadsen Thank you for explaining it to me. Less confused :-)
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T20:07:03.553Z
Answers.Text: So for the number of different types of pieces on the board. The number of unique piece frequencies are:-  **1:= 1** , **2:= 94** , **3:= 2168** , **4:= 19296** , **5:= 71628** ,**6:= 91416**
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-31T20:47:25.583Z
Answers.Text: @DagOskarMadsen Here is a link to a zip containing a csv of all the unique piece frequencies. http://sdrv.ms/1beLLxG
Answers.UserDisplayName: Adam Speight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-01-30T02:44:18.433Z
Answers.LastActivityDate: 2014-01-30T02:44:18.433Z
Answers.UserDisplayName: Adam Speight
Body: <p>My question concerns the total material available on the chess board (black+white pieces). At the very beginning of a game, there are 2 Kings, 2 Queens, 4 Rooks, 4 Bishops, 4 Knights and 16 pawns. These can be represented by an array (2, 2, 4, 4, 4, 16). As the game progresses, the total amount of material will change, thus the array will change. My question is as follows. Looking at all theoretically possible games played from the initial position, how many unique arrays are possible to reach? The fact that a pawn can be promoted to any light or heavy piece makes the problem even more tricky!</p>
  
  <p>Initial Board</p>
  
  <pre><code>16 Pawns
   4 Rooks
   4 Bishops
   4 Knights
   2 Queens
   2 Kings
  </code></pre>
  
  <p>After a pawn capture</p>
  
  <pre><code>15 Pawns
   4 Rooks
   4 Bishops
   4 Knights
   2 Queens
   2 Kings 
  </code></pre>
  
  <p>Only kings left</p>
  
  <pre><code> 0 Pawns
   0 Rooks
   0 Bishops
   0 Knights
   0 Queens
   2 Kings
  </code></pre>
  
  <p>But it get more complex when you include pawn promotion (to any piece excluding pawn and king). </p>
  
  <p>So what is the total number of combinations?</p>
  
  <hr>
  
  <p>I've listed 3 combinations above. Here a 6 more</p>
  
  <pre><code> P  R  N  B  Q  K
  32  4  4  4  2  2  Initial Position and remains the same until a capture
  32  3  4  4  2  2  First capture frequency combinations.  
  32  4  3  4  2  2
  32  4  4  3  2  2
  32  4  4  4  1  2
  31  4  4  4  2  2  Pawn 
  etc
  etc
  0  0  0  0  0  2  Only Kings
  </code></pre>
  
  <p>It get tricky at pawn promotion cos each of the 16 pawns can turn in one of 4 pieces (R B N Q).  Which is why I curious to know the total number of (unique piece frequencies)</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T03:38:18.750Z
Comments.Text: What do you mean by 'combinations'?  The number of different board positions possible with the pieces you specified?
Comments.UserDisplayName: Tony Ennis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T03:52:50.353Z
Comments.Text: @TonyEnnis Just the combination of piece frequencies, not board positions.
Comments.UserDisplayName: Adam Speight
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T08:55:44.363Z
Comments.Text: Do you distinguish between white and black pieces?
Comments.UserDisplayName: Dag Oskar Madsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T10:39:52.100Z
Comments.Text: unclear question, would you be more specific @AdamSpeight ?
Comments.UserDisplayName: mounaim
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T19:21:40.477Z
Comments.Text: In a legal game, if all pawns have promoted, then some of the other pieces must have been captured. Do you worry about that in your calculation?
Comments.UserDisplayName: Dag Oskar Madsen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-01-27T19:59:09.460Z
Comments.Text: @DagOskarMadsen Yep, so long as it unique. Eg if one position results in 111112 and another has the same it is just one combination of frequencies. Another results in 121112 that be a different combination.
Comments.UserDisplayName: Adam Speight
Tags: <mathematics><pieces>
Title: How many possible combinations for the number of pieces on the board?
ThreadText: # How many possible combinations for the number of pieces on the board?
  
  (Asked by: username_0 on 2014-01-27)
  
  My question concerns the total material available on the chess board (black+white pieces). At the very beginning of a game, there are 2 Kings, 2 Queens, 4 Rooks, 4 Bishops, 4 Knights and 16 pawns. These can be represented by an array (2, 2, 4, 4, 4, 16). As the game progresses, the total amount of material will change, thus the array will change. My question is as follows. Looking at all theoretically possible games played from the initial position, how many unique arrays are possible to reach? The fact that a pawn can be promoted to any light or heavy piece makes the problem even more tricky!
  Initial Board
  16 Pawns
   4 Rooks
   4 Bishops
   4 Knights
   2 Queens
   2 Kings
  
  After a pawn capture
  15 Pawns
   4 Rooks
   4 Bishops
   4 Knights
   2 Queens
   2 Kings 
  
  Only kings left
   0 Pawns
   0 Rooks
   0 Bishops
   0 Knights
   0 Queens
   2 Kings
  
  But it get more complex when you include pawn promotion (to any piece excluding pawn and king). 
  So what is the total number of combinations?
  
  I've listed 3 combinations above. Here a 6 more
   P  R  N  B  Q  K
  32  4  4  4  2  2  Initial Position and remains the same until a capture
  32  3  4  4  2  2  First capture frequency combinations.  
  32  4  3  4  2  2
  32  4  4  3  2  2
  32  4  4  4  1  2
  31  4  4  4  2  2  Pawn 
  etc
  etc
  0  0  0  0  0  2  Only Kings
  
  It get tricky at pawn promotion cos each of the 16 pawns can turn in one of 4 pieces (R B N Q).  Which is why I curious to know the total number of (unique piece frequencies)
  
  **Tags:** mathematics, pieces
  
  > **Comments:**
  > **username_1**: What do you mean by 'combinations'?  The number of different board positions possible with the pieces you specified?  
  > **username_0**: @TonyEnnis Just the combination of piece frequencies, not board positions.  
  > **username_2**: Do you distinguish between white and black pieces?  
  > **username_3**: unclear question, would you be more specific @AdamSpeight ?  
  > **username_2**: In a legal game, if all pawns have promoted, then some of the other pieces must have been captured. Do you worry about that in your calculation?  
  > **username_0**: @DagOskarMadsen Yep, so long as it unique. Eg if one position results in 111112 and another has the same it is just one combination of frequencies. Another results in 121112 that be a different combination.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2014-01-27. Score: 3
  
  It's :
  numberOfPawnsPieces(=17) * numberOfRooksPieces(=5) * numberOfBishopsPieces(=5) * numberOfKnightsPieces(=5) * numberOfQueensPieces(=3) * numberOfKingsPieces(=1)
  = 6375 
  I added one to each number of same piece in case there is no one of its kind(for queens for example, there may be two queens, one queen, or none), except for Kings where there always must be 2 kings on the board, so the number of combinations for kings number is only 1.  
  **
  EDIT : In cas there is promotions of pawns
  **
  My idea to tackle this is to separate all possible cases, i.e. when there is promotion of 1 pawn, promotion of 2 pawns,...,promotion of 8 pawns. ( 8 pawns is the maximum number of possible promotions )
  Generally speaking, when x pawns are promoted, we will proceed same as above, but the number of pawns will be in each case (16-x), plus an other group of 4 * x possibly created pieces. Finally we will sum all over the cases :
                  17*5*5*5*3*1 + SUM[x=1-->16,(16-x+1)*5*5*5*3*(4*x)] = **1 230 375**
  
  This is approximate, I may have forgotten some cases, or added some positions that are just impossible to happen in a chess game,...etc.
  
  > **Comments:**
  > **username_2**: This is the correct number if you don't include pawn promotion.  
  > **username_3**: @DagOskarMadsen would you please check my edit for the answer ?  
  > **username_3**: @username_0 check my edit for the answer :)  
  > **username_2**: Actually there can be 16 promotions: http://chess.stackexchange.com/questions/4128/shortest-game-with-18-queens, but in a legal game then some of the other pieces must have bee captured on the way. If you only consider legal games, then this becomes a very hard chess question rather than a mathematical question.  
  > **username_3**: Thanks @DagOskarMadsen for this beautiful game with 16 queens, I thought this was just impossible !  
  > **username_2**: Your answer now is much too large since you are counting the same piece distributions many times. Your answer would have been correct if promoted pieces were to be considered different from the starting pieces. For instance you are counting two kings and a queen as different from two kings and a promoted queen.  
  > **username_3**: you're right @DagOskarMadsen, my answer may involve duplicated endgames, I will try to work on this :)  
  
  ---
  
  ### Answer by username_4 on 2015-10-15. Score: 2
  
  Initialy I posted that only 8 promotions for both sides are posible because pawns are oposed in the same file and to promote one have to be taken.
  Edited:
  I think that for each promotion one pawn or a piece shoud be taken. Because pawns are in front of each other ,blacks and whites ,to promote one of both have to move to the side(take another piece or pawn) or be taken. then I recalculated the final result to 80094 diferent legal piece combinations. I created this script to show all (i modified thanks to the comments of username_5)
  (function (pieceset) {
      'use strict';
      var n = 0,
          cc = function cc(arr) {
              var temparr=arr.slice(0);
              while (temparr[0]>=0) {
                  while (temparr[1]>=0) {
                      while (temparr[2]>=0) {
                          while (temparr[3]>=0) {
                              while (temparr[4]>=0) {
                                  var maxp = 0;
                                  var nump = temparr[1]+temparr[2]+temparr[3]+temparr[4]; 
                                  if (temparr[1]>4) maxp+=(temparr[1]-4);
                                  if (temparr[2]>4) maxp+=(temparr[2]-4);
                                  if (temparr[3]>4) maxp+=(temparr[3]-4);
                                  if (temparr[4]>2) maxp+=(temparr[4]-2);
                                  nump = nump - maxp;
                                  if ((maxp+temparr[0]<=16)&&((nump+temparr[0]+(maxp*2))<=30)) {
                                      n++;
                                      console.log(n,"->",temparr);
                                  }
                                  temparr[4]=temparr[4]-1;
                              }
                              temparr[4]=arr[4];
                              temparr[3]=temparr[3]-1;
                          }
                          temparr[3]=arr[3];
                          temparr[2]=temparr[2]-1;
                      }
                      temparr[2]=arr[2];
                      temparr[1]=temparr[1]-1;
                  }
                  temparr[1]=arr[1];
                  temparr[0]=temparr[0]-1;
              }
              return 0;
          };
      cc(pieceset);
  }([16,20,20,20,18,2]));
  
  When you run it it print lines like this:
  1 '->' [ 16, 4, 4, 4, 2, 2 ]
  
  the fist number its the combination number followed by Pawns,Rooks,Knights,Bishops,Queens,Kings. The fist line corresponds the fist position with full board, and the last with the two kings alone.
  You can try here : https://repl.it/xlO/4
  
  > **Comments:**
  > **username_5**: Actually, for a pawn to able to promote it is necessary that the pawn in front moves aside (taking a piece or another pawn) or is taken.  
  
  ---
  
  ### Answer by username_0 on 2014-01-30. Score: 1
  
  I know that the upper limit can not be greater than 2304000
  Which is the answer to the following
  16 (Pawns) * 20 (Rooks) * 20 (Knights) * 20 (Bishops) * 18 (Queens)
  
  But not all of those are possible, so doing a quick programming
   c:= 0
   p:= 0 .. 16
   r:= 0 .. 20
   b:= 0 .. 20
   n:= 0 .. 20
   q:= 0 .. 18
   if Sum( p, r, b, n, q, 2) <= 32 then c+=1
  
  Calculates c to be 305090 combinations. (218 < c < 219)
  If I just focus on end games (no pawns) I calculate c to be 3060  211 < c < 212
  Is my algorithm producing the correct results?
  
  > **Comments:**
  > **username_2**: There are some other restrictions. If there are 20 rooks, then there cannot be more than 4 knights, for instance.  
  > **username_0**: @DagOskarMadsen Good point, which suggest the value is lower than these upper bounds.  
  > **username_0**: Adding the constraint __Sum(r,n,b,a)<= (20-p)__ reduces the combinations to **53068** and **3060**  
  > **username_2**: The question now says "...all theoretically possible games played from the initial position ....". If you have a large number of promotions, then there must have been several captures on the way. It is going to be very hard to calculate the exact answer, maybe an upper bound is the most we can hope for.  
  > **username_2**: I think the constraint should be Sum(r,n,b,q)<= (30-p)  
  > **username_2**: No, it's more subtle than in my previous comment. The constraint is max(r,4)+max(n,4)+max(b,4)+max(q,2)<=(30-p)  
  > **username_0**: @DagOskarMadsen I suspect that constraint will produce the wrong value. Then can be less than 4 rooks on the board.  
  > **username_2**: Sure. There are 16 pawns that can promote, so from promotions we get max(r-4,0)+max(n-4,0)+max(b-4,0)+max(q-2,0)<=(16-p). This is equivalent to what I wrote. Trust me, I am a mathematician :)  
  > **username_0**: @DagOskarMadsen I ain't. So could you explain (like I am 5) how you came that expression.eg  max(q-2,0)? It's possible to have all the 16 pawns promoted to queens and still have the original 2 queen also. Which is 18 queens.  Me Confused. :-(  
  > **username_2**: If you have 18 queens, then 16 of them must have been promoted. max(q-2,0)=max(16,0)=16. Similarly, max(r-4,0) counts the number of rooks that *must* have been promoted. For instance if there are 6 rooks, then at least max(r-4,0)=max(2,0)=2 of them must have been promoted.  
  > **username_2**: The formula then counts on the number of pieces on the board that *must* be promoted pieces and compares with the number of missing pawns.  
  > **username_0**: So I calculate the answers to be **164603** and **32275** (end game). @DagOskarMadsen Thank you for explaining it to me. Less confused :-)  
  > **username_0**: So for the number of different types of pieces on the board. The number of unique piece frequencies are:-  **1:= 1** , **2:= 94** , **3:= 2168** , **4:= 19296** , **5:= 71628** ,**6:= 91416**  
  > **username_0**: @DagOskarMadsen Here is a link to a zip containing a csv of all the unique piece frequencies. http://sdrv.ms/1beLLxG  
  > **username_6**: Impossible. Some of those pawns have to take other things to clear the way for them to be promoted or they need to be taken for promotions to happen.  
  
  ---
  
  