5

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.

  • 2
    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. – Pete Becker Apr 18 '15 at 10:29
  • I'm using an engine I made entirely on my own, not based on any standard engine. – TigerhawkT3 Apr 18 '15 at 21:20
  • But surely it has a possible move generation routine? – RemcoGerlich Apr 20 '15 at 7:35
  • 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. – RemcoGerlich Apr 20 '15 at 7:38
  • I added underpromotion to the latest version of my chess program. Its (nonexistent) playerbase breathed a collective sigh of relief. – TigerhawkT3 Sep 18 '15 at 2:32
9

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.

  • 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? – TigerhawkT3 Apr 18 '15 at 4:25
  • 2
    @TigerhawkT3 yes, yes you can. – Tony Ennis Apr 18 '15 at 4:30
  • In your second example, why is the Q promotion stalemate? Is the diagram perhaps incomplete, or am I finally losing it? – firtydank Apr 18 '15 at 6:04
  • @firtydank you're not losing it, a bishop on d5 was missing, thanks for pointing it out :) – Phonon Apr 18 '15 at 6:21
  • 1
    @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. – Phonon Apr 18 '15 at 7:28
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.

1

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.

  • 1
    Promotion to knight is more common than promotion to rook (about 80% more common in the copy of Million Base I checked). – Stephen Apr 21 '15 at 10:56
1

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

  • 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. – TigerhawkT3 Apr 20 '15 at 19:09
  • @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. – Stephen Apr 20 '15 at 20:33
  • 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 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? – TigerhawkT3 Apr 20 '15 at 21:20
  • @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. – Stephen Apr 21 '15 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.