Answers.Body: <h3><strong>Database</strong> : <a href="https://chesscompiled.com/#archive" rel="noreferrer">Chess Compiled</a> 2019-2022 2500+ ELO</h3>
  <h3><strong>Methodology</strong> :</h3>
  <ul>
  <li>I first passed it through <a href="https://chess.stackexchange.com/users/12951/kentdjb">kentdjb's</a> <a href="https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/" rel="noreferrer">pgn-extract</a> to remove erroneous games from the db (you could restrict it by openings here) :</li>
  </ul>
  <pre><code>pgn-extract -o valid.pgn merged_2019_2022_25.pgn
  </code></pre>
  <ul>
  <li>I then wrote <a href="https://codeberg.org/signed/chess-dessict" rel="noreferrer">a python script</a> (using Python chess) that extracts what piece moved and the move from a game and puts it into a <code>pandas</code> <code>DataFrame</code> and then to a CSV file</li>
  </ul>
  <pre><code>....
  for move in game.mainline_moves():
      move_info = {
          'piece': board.piece_at(move.from_square).symbol().upper() if board.piece_at(move.from_square) is not None else None,  # noqa: E501
          'move': board.san(move).upper()
          }
      moves.append(move_info)
      board.push(move)
  df = pd.DataFrame(moves)
  df.to_csv(&quot;moves.csv&quot;)
  </code></pre>
  <ul>
  <li>Passing it back to a DF and counting it :</li>
  </ul>
  <pre><code>df = pd.read_csv(&quot;./moves_up.csv&quot;)
  print(df.groupby('PIECE').count())
  print(df.groupby('MOVE').count())
  </code></pre>
  <hr />
  <h3>Results</h3>
  <h4>Whole database :</h4>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Piece</th>
  <th>N moves</th>
  <th>Average</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>P</td>
  <td>2072118</td>
  <td>23.058</td>
  </tr>
  <tr>
  <td>R</td>
  <td>1512889</td>
  <td>16.835</td>
  </tr>
  <tr>
  <td>N</td>
  <td>1403186</td>
  <td>15.615</td>
  </tr>
  <tr>
  <td>B</td>
  <td>1253473</td>
  <td>13.949</td>
  </tr>
  <tr>
  <td>K</td>
  <td>1109101</td>
  <td>12.342</td>
  </tr>
  <tr>
  <td>Q</td>
  <td>963072</td>
  <td>10.717</td>
  </tr>
  <tr>
  <td>Total</td>
  <td>8313839</td>
  <td></td>
  </tr>
  <tr>
  <td>Number of Games</td>
  <td>89864</td>
  <td></td>
  </tr>
  <tr>
  <td>Average number of half-moves in a game</td>
  <td>92.52</td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div><hr />
  <p>Extracted are the move themselves (5731 distinct entries, multiple pieces (i.e. <code>QF6F5</code>), check/checkmate, and promotions are counted as their own entries):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Move</th>
  <th>Count</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>O-O</td>
  <td>144493</td>
  </tr>
  <tr>
  <td>NF6</td>
  <td>101235</td>
  </tr>
  <tr>
  <td>NF3</td>
  <td>100404</td>
  </tr>
  <tr>
  <td>D4</td>
  <td>89831</td>
  </tr>
  <tr>
  <td>D5</td>
  <td>80752</td>
  </tr>
  <tr>
  <td>E4</td>
  <td>80105</td>
  </tr>
  <tr>
  <td>NC3</td>
  <td>77145</td>
  </tr>
  <tr>
  <td>C4</td>
  <td>72839</td>
  </tr>
  <tr>
  <td>E5</td>
  <td>72662</td>
  </tr>
  <tr>
  <td>C5</td>
  <td>71730</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The most played in promotion is (<code>A8=Q</code>) the 931st move overall, having been played 783 times, and the most played under promotion is actually <code>E8=N+</code> (2667th, played 13 times)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T20:02:08.320Z
Answers.Text: Average moves: Surely 92,52 are *half*moves? (Also, with longer games I expect more R - R vs R is the most prevalent endgame, AFAIK)
Answers.UserDisplayName: Hauke Reddmann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T20:16:57.100Z
Answers.Text: Yes, halfmoves @HaukeReddmann
Answers.UserDisplayName: Nicolas Formichella
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T10:05:18.693Z
Answers.LastActivityDate: 2023-08-21T20:35:24.040Z
Answers.LastEditDate: 2023-08-21T20:35:24.040Z
Answers.UserDisplayName: Nicolas Formichella
Body: <p>I suppose K the least (endgame will up the ante for K, but not that many games
  will reach the endgame) and N the most (the knight is slow in regrouping) but
  I don't have access to a megabase. I expect the exact percentages to be dependent
  on which database you use (e.g. only GM games) but the general trend should stay.
  It seems to be a close call, as this sample shows:</p>
  <p>German Youth Ch 2023 (3500 games), approx : B 40000 N 45000 R 40000 Q 35000 K 35000</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-18T03:50:36.400Z
Comments.Text: This is interesting. Get the stats by opening such as sicilian and compare with other opening like ruy lopez. Another is to get the strong player's stats on sicilian and compare it with a weaker player's stats. I play french defense as black, how my average would compare with strong GM's who play those opening as black too. So now if I have 2 candidate moves available to choose, I will go for the average from strong players stats. This is fun.
  Idea:  a chess GUI can be developed to show this stats.
Comments.UserDisplayName: ferdy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-18T10:17:25.923Z
Comments.Text: +1, but did you really mean 'most moves in an average game' (in this case, you'd need to define 'average game') rather than 'on average in a chess game'?
Comments.UserDisplayName: Hauptideal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-18T17:55:21.743Z
Comments.Text: @Hauptideal: After 50 years English still isn't my mother tongue :-) Indeed your version is better. I edit it.
Comments.UserDisplayName: Hauke Reddmann
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-21T23:27:57.863Z
Comments.Text: Also do you mean for an individual piece starting on one home square or all moves of that piece type? An individual pawn can only move 7 squares but there are 8 pawns.
Comments.UserDisplayName: qwr
Tags: <statistics>
Title: Which officer type makes (on average) the most moves in a chess game?
ThreadText: # Which officer type makes (on average) the most moves in a chess game?
  
  (Asked by: username_0 on 2023-08-17)
  
  I suppose K the least (endgame will up the ante for K, but not that many games
  will reach the endgame) and N the most (the knight is slow in regrouping) but
  I don't have access to a megabase. I expect the exact percentages to be dependent
  on which database you use (e.g. only GM games) but the general trend should stay.
  It seems to be a close call, as this sample shows:
  
  German Youth Ch 2023 (3500 games), approx : B 40000 N 45000 R 40000 Q 35000 K 35000
  
  **Tags:** statistics
  
  > **Comments:**
  > **username_1**: This is interesting. Get the stats by opening such as sicilian and compare with other opening like ruy lopez. Another is to get the strong player's stats on sicilian and compare it with a weaker player's stats. I play french defense as black, how my average would compare with strong GM's who play those opening as black too. So now if I have 2 candidate moves available to choose, I will go for the average from strong players stats. This is fun. Idea:  a chess GUI can be developed to show this stats.  
  > **username_2**: +1, but did you really mean 'most moves in an average game' (in this case, you'd need to define 'average game') rather than 'on average in a chess game'?  
  > **username_0**: @username_2: After 50 years English still isn't my mother tongue :-) Indeed your version is better. I edit it.  
  > **username_3**: Also do you mean for an individual piece starting on one home square or all moves of that piece type? An individual pawn can only move 7 squares but there are 8 pawns.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2023-08-21. Score: 9
  
  ### **Database** : [Chess Compiled](https://chesscompiled.com/#archive) 2019-2022 2500+ ELO
  
  ### **Methodology** :
  
  * I first passed it through [kentdjb's](https://chess.stackexchange.com/users/12951/kentdjb) [pgn-extract](https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/) to remove erroneous games from the db (you could restrict it by openings here) :
  
  ```
  pgn-extract -o valid.pgn merged_2019_2022_25.pgn
  
  ```
  
  * I then wrote [a python script](https://codeberg.org/signed/chess-dessict) (using Python chess) that extracts what piece moved and the move from a game and puts it into a `pandas` `DataFrame` and then to a CSV file
  
  ```
  ....
  for move in game.mainline_moves():
      move_info = {
          'piece': board.piece_at(move.from_square).symbol().upper() if board.piece_at(move.from_square) is not None else None,  # noqa: E501
          'move': board.san(move).upper()
          }
      moves.append(move_info)
      board.push(move)
  df = pd.DataFrame(moves)
  df.to_csv("moves.csv")
  
  ```
  
  * Passing it back to a DF and counting it :
  
  ```
  df = pd.read_csv("./moves_up.csv")
  print(df.groupby('PIECE').count())
  print(df.groupby('MOVE').count())
  
  ```
  
  ---
  
  ### Results
  
  #### Whole database :
  
  | Piece | N moves | Average |
  | --- | --- | --- |
  | P | 2072118 | 23.058 |
  | R | 1512889 | 16.835 |
  | N | 1403186 | 15.615 |
  | B | 1253473 | 13.949 |
  | K | 1109101 | 12.342 |
  | Q | 963072 | 10.717 |
  | Total | 8313839 |  |
  | Number of Games | 89864 |  |
  | Average number of half-moves in a game | 92.52 |  |
  
  ---
  
  Extracted are the move themselves (5731 distinct entries, multiple pieces (i.e. `QF6F5`), check/checkmate, and promotions are counted as their own entries):
  
  | Move | Count |
  | --- | --- |
  | O-O | 144493 |
  | NF6 | 101235 |
  | NF3 | 100404 |
  | D4 | 89831 |
  | D5 | 80752 |
  | E4 | 80105 |
  | NC3 | 77145 |
  | C4 | 72839 |
  | E5 | 72662 |
  | C5 | 71730 |
  
  The most played in promotion is (`A8=Q`) the 931st move overall, having been played 783 times, and the most played under promotion is actually `E8=N+` (2667th, played 13 times)
  
  > **Comments:**
  > **username_0**: Average moves: Surely 92,52 are *half*moves? (Also, with longer games I expect more R - R vs R is the most prevalent endgame, AFAIK)  
  > **username_4**: Yes, halfmoves @username_0  
  
  ---
  
  