25

I am trying to write a simple chess program, and as part of this I am writing methods to find all valid moves. I can detect pins and have no trouble leaving out the moves that would result in the moving player being in check, except for one situation I am not sure about.

After an en passant capture, not only is the square previously occupied by the capturing pawn now vacant, but so is the square of the captured pawn. Is there any position at all where capturing en passant results in a discovered check on the king of the player that is capturing en passant, not because the capturing pawn was pinned, but because the check was previously stopped by the captured pawn?

I think this situation is simply not possible, at the very least I can't think of a position and series of moves that results in this situation; the fact that you have to capture en passant at the first opportunity means that either the pawn that should later capture en passant is pinned and can't advance to the fifth rank, or the check is blocked by a different piece anyway. Unfortunately I am having trouble ruling out there is some counter-intuitive position where this might happen. Could someone confirm my suspicions (or provide a counter-example)?

  • 2
    Let's say the captured pawn is black. If it was blocking a check on white, it means that white was in check before the black pawn move, which means that white was in check after white's last move, which would be illegal. Therefore it is not possible for a pawn that can be captured en passant to block a check on the opponent's king. – itub Aug 25 '17 at 16:08
  • 4
  • @bof Thank you, but that is actually not what I meant. This part is not clear in the question, I will edit it now. – 11684 Aug 26 '17 at 9:14
  • The question is asking about pins, but the title still asks about discovered checks. – bof Aug 26 '17 at 9:28
  • 1
    @IAPetrHarasimovic Does the definition of a pin require that the pinned piece be unable to move in any direction? In the position after 1.e4 e5 2.f4 exf4 3.Nf3 Qe6 4.Bb6 Qxe4+ 5.Kf2 Nf6 I think most players would say that 6.Re1 "pins" the black queen, although she is free to move forwards and backwards. – bof Aug 26 '17 at 22:41
31

Really interesting question. I think the following shows that such a situation is sort of possible, depending on how you define the pin:

[StartFlipped "0"]
[FEN "7k/4p3/8/2KP3r/8/8/8/8 b - - 0 1"]

1... e5

and 2. dxe6 is illegal.

The check would go from being stopped by both pawns, to being stopped by neither.

  • Incidentally, this is not how I would have defined a pin when writing the question, but this is exactly what I wanted to know. A better formulation for my question I realise now is if it is safe to assume capturing en passant is always legal (i.e. you don't put your king in check by an en passant capture) if 1) the conditions for capturing en passant are met and 2) the capturing pawn is not pinned. Both of which are met by your counterexample, but ex6 is still illegal. Many thanks! – 11684 Aug 25 '17 at 16:29
  • I can't see the position on my phone, I am assuming it exhibits a rook on the same horizontal as both pawns. Theoretically the pawn being captured could also be blocking a bishop. That would have the same effect but such a position couldn't occur if all preceding moves were legal. Yet at least as a test case the procedure should detect such an illegal move too. – IA Petr Harasimovic Aug 26 '17 at 22:10
  • @IAPetrHarasimovic Maybe if it were a high-profile would-be Stockfish competitor, but I'm just programming this because it's fun :) Nonetheless, the way it's programmed now should detect what you're describing as well. – 11684 Aug 27 '17 at 16:16
1

Although this question has been well answered, I wish to share a chess problem that uses the weird mechanism of the pawn being pinned by the taken pawn.

Enjoy!

This problem can be found here on Yet Another Chess Problem Database.

[Title "Brunner, Erich Anselm, Deutsches Wochenschach (8515) 1908-12, White To Move And Selfmate Themselves"]
[FEN "8/8/5Q2/2p3Pk/5R1P/5r2/1PPKB1P1/2NRB3 w - - 0 1"]

1. Ra4 c4 2. Qf7+ Kg4 3. b4 c3#

A small tip for some: a selfmate is a chess problem where one side forces the other side to checkmate them.

The rook on a4 pins the Black pawn such that it cannot take en passant, as that would expose the Black king to check. So thus the Black pawn cannot do that and must move forward with mate.

0

It's possible, but you need to check who's getting checked ( slight pun intended... :-) ).

Let's say it's black's move:

Black moves a pawn two ranks, opening it up to an en passant move from a white pawn. If this move leads to a check on the black king it's an illegal move. If this leads to a check on the white king, white must respond be defending the king and so can't do an en passant move unless that move will protect the king.

If no check is made, white can then make the en passant move. If this leads to a check on the white king it's an illegal move. If it leads to a check on the black king, black must respond by defending the king.

  • 1
    I'm not sure I completely understand your answer, but the way I read it it doesn't answer the question. "If this leads to a check on the white king..." The whole question is whether that could occur, not whether exposing your own king to a check with your move is legal. – 11684 Aug 25 '17 at 23:04
  • My point was that yes, it could happen - as others have showed. You didn't specify if you were concerned about getting yourself in check or getting your opponent in check, hence I looked at all the possibilities, noting that some of them were ilegal moves. Long story short, an en passant move can indeed set the opposing king in check, but never your own as that would be an ilegal move. Sorry if that wasn't entirely clear. – f2k Aug 26 '17 at 8:47
  • Then this doesn't answer the question. I am aware of the consequences pertaining to the legality of a move, I only wanted to know whether a position where the king of the player capturing en passant would be in check. – 11684 Aug 26 '17 at 9:11
  • I'm honestly not sure what your asking anymore. If you're aware of the issue of the legality of the move, then you should know that no move may put your own king in check. Can you make an en passant capture that puts your own king in check? No, of course not. Can you make an en passant capture that puts your opponent's king in check? Yes, you can. – f2k Aug 26 '17 at 15:05
  • 2
    He is asking whether it is safe to assume that taking en passant can never expose your own king to a check. Your answer is that en passant capture cannot expose one's king to a check but it is not correct, it would be possible in some positions. – IA Petr Harasimovic Aug 26 '17 at 22:02

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.