Answers.Body: <p>Underpromotion may be uncommon but it is important in the sense that, on the rare occasions you need it, you really do <strong>NEED</strong> it.</p>
  
  <p>The two basic scenarios, covered in the other answer, are:</p>
  
  <ol>
  <li>Underpromotion to non-queen to avoid stalemating the opponent</li>
  <li>Underpromotion to knight because your next move absolutely needs to be a check</li>
  </ol>
  
  <p>Neither of these situations warrants an "oh, no promotion to knight I guess" response, as if they're being over fussy and should just choose the queen like everyone always does because its the best. The queen <em>isn't</em> the best here and being forced to choose it is likely to cost them the game.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-19T07:56:06.253Z
Answers.LastActivityDate: 2015-04-19T07:56:06.253Z
Answers.UserDisplayName: Simon Jenkins
Answers.Body: <p>While under promoting to a knight is relatively rare, under promoting to a rook is not.</p>
  
  <p>It's not uncommon to promote to a rook in a king vs king and pawn endgames to avoid stalemating the king.  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T10:56:22.587Z
Answers.Text: Promotion to knight is more common than promotion to rook (about 80% more common in the copy of Million Base I checked).
Answers.UserDisplayName: Stephen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T14:37:55.747Z
Answers.LastActivityDate: 2015-04-20T14:37:55.747Z
Answers.UserDisplayName: Bourbon53
Answers.Body: <p>Maybe it's a bit obscure, but how will you check your move generation with promotions? I mean, for testing your move generator, as soon as a promotion happens, you won't have a way to check whether your promotion code is working properly.</p>
  
  <p>Just in case somebody has no idea what I'm tlaking about;
  <a href="http://chessprogramming.wikispaces.com/Perft+Results" rel="nofollow">http://chessprogramming.wikispaces.com/Perft+Results</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T19:09:10.847Z
Answers.Text: Each time it's the computer's turn to move, it looks at all of its available pieces, generates the possible moves for each one, and either picks a move randomly (easy mode) or tries to capture/avoid (hard mode). It doesn't look ahead at all.
Answers.UserDisplayName: TigerhawkT3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T20:33:10.157Z
Answers.Text: @TigerhawkT3: But what Emilio is asking, is how do you know that the set of all possible moves that you generate is correct (except for the omission of underpromotions) if you can't test your code against known Perft results? It doesn't matter whether you look ahead or not, as that's about playing, not move generation.
Answers.UserDisplayName: Stephen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T21:20:26.520Z
Answers.Text: In my program, each type of piece has specific rules about where it can move, with pseudo-legal move generation. For example, a rook can move up/down/left/right as far as it wants, stopped by friendly pieces or the end of the board. [This page](http://chessprogramming.wikispaces.com/Move+Generation) says that Perft "recursively generates moves for the current position and all children up to a certain depth" - my program doesn't check children at all. Could this result in allowing illegal moves?
Answers.UserDisplayName: TigerhawkT3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T06:58:19.053Z
Answers.Text: @TigerhawkT3: No, you don't need to check children. The point is just that it's very easy to get move generation wrong. Perft is a way to check that you got it right. The Perft routine is recursive, but should be easy to write even if you never recursively generate moves in your main code.
Answers.UserDisplayName: Stephen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T18:51:35.163Z
Answers.LastActivityDate: 2015-04-20T18:51:35.163Z
Answers.UserDisplayName: Emilio Díaz
Answers.Body: <p>Well I definitely wouldn't put it as <em>unacceptably incomplete</em>, after all it is a very rare event that you're forced to underpromote into a knight, unless you're fooling around.</p>
  
  <p>That said, there are cases in real games, where you actually have to promote knights (again very rarely, but still every now and then you see one of those), because e.g. you have to promote with a check (otherwise you may get checkmated), so if in such scenarios it's only with knight that you can check, then you really need the knight-promotion option. A random example:</p>
  
  <pre><code>[Title "1.e8=N+ Forced knight promotion"]
  [StartFlipped "0"]
  [fen "3K4/4P3/2qk4/8/8/8/8/8 w - - 0 1"]
  
  1. e8=N+ (1.e8=Q Qc7#)
  </code></pre>
  
  <p>Here's another one: (match between <a href="http://www.chessgames.com/perl/chessgame?gid=1287069" rel="nofollow noreferrer">Tomic vs. Winzbeck</a>)</p>
  
  <pre><code>[Title "Forced N or B promotion else stalemate"]
  [StartFlipped "0"]
  [fen "3rb2k/2P4p/6pP/p2B1pP1/Pp2pP2/1P2K3/8/8 w - - 0 1"]
  
  1. cxd8=N (1. cxd8=B) (1. cxd8=Q)
  </code></pre>
  
  <p>On the other hand, it may also happen that if you promote into anything else than knight, you stalemate the position, so again knight-promotion needed. You'll find tons of examples from <a href="https://chess.stackexchange.com/questions/730/why-would-one-promote-a-pawn-to-a-knight">this chess SE</a> post and links therein.</p>
  
  <p>Whereas if you take online blitz games as example, then most often (for time controls &lt; 5 mins at least) players set their automatic promotion to queen so that in case they're in time trouble and have to promote, they can premove it.</p>
  
  <p>All in all, I would say that you should <em>try</em> to implement it for completeness, and if it turns out difficult for you, then don't worry too much about it, no big deal.</p>
  
  <p>I actually do recall a very fun game between Hikaru Nakamura and Boris Savchenko in the previous world blitz championship, where Nakamura had to underpromote into knight with check in order to avoid a mate in 1, <a href="https://www.youtube.com/watch?v=1-vcBlRNlbQ" rel="nofollow noreferrer">here's the clip</a>, it's only 2 minutes, watch it from the start, but if you just want to see the promotion moment, <a href="https://youtu.be/1-vcBlRNlbQ?t=2m4s" rel="nofollow noreferrer">here it is</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T04:25:21.457Z
Answers.Text: It sounds like it's approximately "not unheard-of" - quite necessary for tournament play, but not much of a problem for the vast majority of games. Can I put this on the back-burner without feeling like a key component has been left out?
Answers.UserDisplayName: TigerhawkT3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T04:30:38.180Z
Answers.Text: @TigerhawkT3 yes, yes you can.
Answers.UserDisplayName: Tony Ennis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T06:04:23.007Z
Answers.Text: In your second example, why is the Q promotion stalemate? Is the diagram perhaps incomplete, or am I finally losing it?
Answers.UserDisplayName: firtydank
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T06:21:44.437Z
Answers.Text: @firtydank you're not losing it, a bishop on d5 was missing, thanks for pointing it out :)
Answers.UserDisplayName: Ellie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T07:12:08.570Z
Answers.Text: The rook vs pawn ending where you have to underpromote isn't thaaat exotic … also there is a trap in the Albin  countergambit, which uses underpromotion: 1. d4 d5 2. c4 e5 3. dxe5 d4 4. e3 Bb4 5. Bd2 dxe3 6. Bxb4 exf2 7. Ke2 fxg1N!
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T07:28:32.853Z
Answers.Text: @BlindKungFuMaster yeah but I didn't want to copy them again here, as they're already in the chess SE link I had ref'ed. But definitely true that it's a more *exotic* line. Just wanted some simple examples that convey the idea.
Answers.UserDisplayName: Ellie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-20T23:46:21.933Z
Answers.Text: There is a famous game between Nakamura and Kramnik in the 2012 Olympiad involving a nice Knight promotion
Answers.UserDisplayName: sco-ish
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-18T03:23:35.000Z
Answers.LastActivityDate: 2015-04-18T06:20:36.897Z
Answers.LastEditDate: 2017-04-13T12:48:53.737Z
Answers.UserDisplayName: Ellie
Body: <p>Is a chess program without the ability to promote to knight unacceptably incomplete?</p>
  
  <p>I have a chess program that implements most basic chess rules, such as en passant and castling. However, promotion automatically chooses a queen, as introducing a decision point there would complicate everything from the AI to the replay system to keybindings.</p>
  
  <p>Is a chess program without promotion to knight just no good, or is the average chess player not likely to ever notice that it's missing? And if they do, would it be similar to "oh, no promotion to knight I guess" or more like "how in the world did someone think this was okay? I bet this wasn't even developed by a chess player!" (a safe bet)? I'm hoping that it's trivial enough to be overlooked, but if it really is important then I'll just have to figure it out.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-18T10:29:41.427Z
Comments.Text: Under-promotion can be a simple part of move generation. Each possible promotion generates four possible moves; the engine doesn't care that f8=Q and f8=N are both promotions of the same pawn.
Comments.UserDisplayName: Pete Becker
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-18T21:20:05.730Z
Comments.Text: I'm using an engine I made entirely on my own, not based on any standard engine.
Comments.UserDisplayName: TigerhawkT3
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-20T07:35:44.357Z
Comments.Text: But surely it has a possible move generation routine?
Comments.UserDisplayName: RemcoGerlich
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-20T07:38:08.287Z
Comments.Text: I *feel* that underpromotion is too rare to matter in 1 in 10 games, but that it is common enough to matter in 1 in 50 games (mostly promoting to knight with check for tactical reasons). But I don't have any numbers to back that up, so don't see this as an answer, I'm just curious if the answer is going to be somewhere in that range.
Comments.UserDisplayName: RemcoGerlich
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-18T02:32:16.810Z
Comments.Text: I added underpromotion to the latest version of my chess program. Its (nonexistent) playerbase breathed a collective sigh of relief.
Comments.UserDisplayName: TigerhawkT3
Tags: <software><pawn-promotion>
Title: How common/important is promotion to knight?
ThreadText: # How common/important is promotion to knight?
  
  (Asked by: username_0 on 2015-04-18)
  
  Is a chess program without the ability to promote to knight unacceptably incomplete?
  
  I have a chess program that implements most basic chess rules, such as en passant and castling. However, promotion automatically chooses a queen, as introducing a decision point there would complicate everything from the AI to the replay system to keybindings.
  
  Is a chess program without promotion to knight just no good, or is the average chess player not likely to ever notice that it's missing? And if they do, would it be similar to "oh, no promotion to knight I guess" or more like "how in the world did someone think this was okay? I bet this wasn't even developed by a chess player!" (a safe bet)? I'm hoping that it's trivial enough to be overlooked, but if it really is important then I'll just have to figure it out.
  
  **Tags:** software, pawn-promotion
  
  > **Comments:**
  > **username_1**: Under-promotion can be a simple part of move generation. Each possible promotion generates four possible moves; the engine doesn't care that f8=Q and f8=N are both promotions of the same pawn.  
  > **username_0**: I'm using an engine I made entirely on my own, not based on any standard engine.  
  > **username_2**: But surely it has a possible move generation routine?  
  > **username_2**: I *feel* that underpromotion is too rare to matter in 1 in 10 games, but that it is common enough to matter in 1 in 50 games (mostly promoting to knight with check for tactical reasons). But I don't have any numbers to back that up, so don't see this as an answer, I'm just curious if the answer is going to be somewhere in that range.  
  > **username_0**: I added underpromotion to the latest version of my chess program. Its (nonexistent) playerbase breathed a collective sigh of relief.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_7 on 2015-04-18. Score: 9 | Accepted answer
  
  Well I definitely wouldn't put it as unacceptably incomplete, after all it is a very rare event that you're forced to underpromote into a knight, unless you're fooling around.
  That said, there are cases in real games, where you actually have to promote knights (again very rarely, but still every now and then you see one of those), because e.g. you have to promote with a check (otherwise you may get checkmated), so if in such scenarios it's only with knight that you can check, then you really need the knight-promotion option. A random example:
  [Title "1.e8=N+ Forced knight promotion"]
  [StartFlipped "0"]
  [fen "3K4/4P3/2qk4/8/8/8/8/8 w - - 0 1"]
  
  1. e8=N+ (1.e8=Q Qc7#)
  
  Here's another one: (match between Tomic vs. Winzbeck)
  [Title "Forced N or B promotion else stalemate"]
  [StartFlipped "0"]
  [fen "3rb2k/2P4p/6pP/p2B1pP1/Pp2pP2/1P2K3/8/8 w - - 0 1"]
  
  1. cxd8=N (1. cxd8=B) (1. cxd8=Q)
  
  On the other hand, it may also happen that if you promote into anything else than knight, you stalemate the position, so again knight-promotion needed. You'll find tons of examples from this chess SE post and links therein.
  Whereas if you take online blitz games as example, then most often (for time controls < 5 mins at least) players set their automatic promotion to queen so that in case they're in time trouble and have to promote, they can premove it.
  All in all, I would say that you should try to implement it for completeness, and if it turns out difficult for you, then don't worry too much about it, no big deal.
  I actually do recall a very fun game between Hikaru Nakamura and Boris Savchenko in the previous world blitz championship, where Nakamura had to underpromote into knight with check in order to avoid a mate in 1, here's the clip, it's only 2 minutes, watch it from the start, but if you just want to see the promotion moment, here it is.
  
  > **Comments:**
  > **username_0**: It sounds like it's approximately "not unheard-of" - quite necessary for tournament play, but not much of a problem for the vast majority of games. Can I put this on the back-burner without feeling like a key component has been left out?  
  > **username_8**: @username_0 yes, yes you can.  
  > **username_9**: In your second example, why is the Q promotion stalemate? Is the diagram perhaps incomplete, or am I finally losing it?  
  > **username_7**: @username_9 you're not losing it, a bishop on d5 was missing, thanks for pointing it out :)  
  > **username_10**: The rook vs pawn ending where you have to underpromote isn't thaaat exotic … also there is a trap in the Albin  countergambit, which uses underpromotion: 1. d4 d5 2. c4 e5 3. dxe5 d4 4. e3 Bb4 5. Bd2 dxe3 6. Bxb4 exf2 7. Ke2 fxg1N!  
  > **username_7**: @username_10 yeah but I didn't want to copy them again here, as they're already in the chess SE link I had ref'ed. But definitely true that it's a more *exotic* line. Just wanted some simple examples that convey the idea.  
  > **username_11**: There is a famous game between Nakamura and Kramnik in the 2012 Olympiad involving a nice Knight promotion  
  
  ---
  
  ### Answer by username_3 on 2015-04-19. Score: 3
  
  Underpromotion may be uncommon but it is important in the sense that, on the rare occasions you need it, you really do **NEED** it.
  
  The two basic scenarios, covered in the other answer, are:
  
  1. Underpromotion to non-queen to avoid stalemating the opponent
  2. Underpromotion to knight because your next move absolutely needs to be a check
  
  Neither of these situations warrants an "oh, no promotion to knight I guess" response, as if they're being over fussy and should just choose the queen like everyone always does because its the best. The queen *isn't* the best here and being forced to choose it is likely to cost them the game.
  
  
  ---
  
  ### Answer by username_4 on 2015-04-20. Score: 2
  
  While under promoting to a knight is relatively rare, under promoting to a rook is not.
  
  It's not uncommon to promote to a rook in a king vs king and pawn endgames to avoid stalemating the king.
  
  > **Comments:**
  > **username_5**: Promotion to knight is more common than promotion to rook (about 80% more common in the copy of Million Base I checked).  
  
  ---
  
  ### Answer by username_6 on 2015-04-20. Score: 2
  
  Maybe it's a bit obscure, but how will you check your move generation with promotions? I mean, for testing your move generator, as soon as a promotion happens, you won't have a way to check whether your promotion code is working properly.
  
  Just in case somebody has no idea what I'm tlaking about;
  <http://chessprogramming.wikispaces.com/Perft+Results>
  
  > **Comments:**
  > **username_0**: Each time it's the computer's turn to move, it looks at all of its available pieces, generates the possible moves for each one, and either picks a move randomly (easy mode) or tries to capture/avoid (hard mode). It doesn't look ahead at all.  
  > **username_5**: @username_0: But what Emilio is asking, is how do you know that the set of all possible moves that you generate is correct (except for the omission of underpromotions) if you can't test your code against known Perft results? It doesn't matter whether you look ahead or not, as that's about playing, not move generation.  
  > **username_0**: In my program, each type of piece has specific rules about where it can move, with pseudo-legal move generation. For example, a rook can move up/down/left/right as far as it wants, stopped by friendly pieces or the end of the board. [This page](http://chessprogramming.wikispaces.com/Move+Generation) says that Perft "recursively generates moves for the current position and all children up to a certain depth" - my program doesn't check children at all. Could this result in allowing illegal moves?  
  > **username_5**: @username_0: No, you don't need to check children. The point is just that it's very easy to get move generation wrong. Perft is a way to check that you got it right. The Perft routine is recursive, but should be easy to write even if you never recursively generate moves in your main code.  
  
  ---
  
  