Answers.Body: <p>So the situation is that there would be an en passant opportunity, except it's not a legal move because the pawn on e5 is pinned. Both choices are functionally the same as the tree of legal moves from the position defined by each FEN is the same. Both ways will work perfectly fine, as it's in the end the same position.</p>
  <p>I guess the <a href="https://www.chessprogramming.org/Forsyth-Edwards_Notation#En_passant_target_square" rel="noreferrer">chess programming Wiki</a> is the closest we're going to get to a consensus description of FEN, and it says:</p>
  <blockquote>
  <p>The en passant target square is specified after a double push of a pawn, no matter whether an en passant capture is really possible or not.</p>
  </blockquote>
  <p>That's pretty clear -- it's what you do.</p>
  <p>That's surprising to me. Following the footnotes, <a href="http://www.talkchess.com/forum3/viewtopic.php?topic_view=threads&amp;p=396838&amp;t=37879#p396838" rel="noreferrer">there is a comment by the original author of FEN</a> calling it a mistake, and in general there are a lot of people unhappy with the choice in the standard (it actually says to record <em>all</em> double pawn moves in the en passant field, even if there's no adjacent pawn -- e.g., after 1.e4).</p>
  <p>In the end it's a tradeoff between checking for the existence of a legal en passant move at the time of generating the FEN versus at the time of using it. In my opinion it would be nicest to check when generating, so what PyChess does. But what you do is what is written down in the standard and probably in common test sets.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-15T08:20:33.147Z
Answers.LastActivityDate: 2023-12-15T08:20:33.147Z
Answers.UserDisplayName: RemcoGerlich
Body: <p>I am trying to create a scalable chess move generator in python for my chess engine. My legal move benchmark comes from &quot;<a href="https://python-chess.readthedocs.io/en/latest/" rel="nofollow noreferrer">python-chess</a>&quot; library.
  My move generator generates an en passant opportunity at <strong>f6</strong> by playing <strong>f7f5</strong> on <strong>r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44</strong>, but python-chess library does not generate an en passant opportunity.</p>
  <p>From what I understand about En Passant, my move generator is correct and python-chess library is incorrect. Is my understanding correct or am I missing something?</p>
  <pre><code>Testing FEN: r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44
          My Move Generator:: r3r3/3k2pp/p5Q1/PP2Pp2/b6b/2RP4/2n1K3/1NB1n3 w - f6 0 45
          Python-Chess library generator:: r3r3/3k2pp/p5Q1/PP2Pp2/b6b/2RP4/2n1K3/1NB1n3 w - - 0 45
  FAILED!
  </code></pre>
  <pre><code>[FEN &quot;r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44&quot;]
  </code></pre>
  
Tags: <engines><python><en-passant>
Title: Is there an en passant opportunity in this position?
ThreadText: # Is there an en passant opportunity in this position?
  
  (Asked by: username_0 on 2023-12-15)
  
  I am trying to create a scalable chess move generator in python for my chess engine. My legal move benchmark comes from "python-chess" library.
  My move generator generates an en passant opportunity at f6 by playing f7f5 on r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44, but python-chess library does not generate an en passant opportunity.
  From what I understand about En Passant, my move generator is correct and python-chess library is incorrect. Is my understanding correct or am I missing something?
  Testing FEN: r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44
          My Move Generator:: r3r3/3k2pp/p5Q1/PP2Pp2/b6b/2RP4/2n1K3/1NB1n3 w - f6 0 45
          Python-Chess library generator:: r3r3/3k2pp/p5Q1/PP2Pp2/b6b/2RP4/2n1K3/1NB1n3 w - - 0 45
  FAILED!
  
  [FEN "r3r3/3k1ppp/p5Q1/PP2P3/b6b/2RP4/2n1K3/1NB1n3 b - - 8 44"]
  
  **Tags:** engines, python, en-passant
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-12-15. Score: 5 | Accepted answer
  
  So the situation is that there would be an en passant opportunity, except it's not a legal move because the pawn on e5 is pinned. Both choices are functionally the same as the tree of legal moves from the position defined by each FEN is the same. Both ways will work perfectly fine, as it's in the end the same position.
  
  I guess the [chess programming Wiki](https://www.chessprogramming.org/Forsyth-Edwards_Notation#En_passant_target_square) is the closest we're going to get to a consensus description of FEN, and it says:
  
  > The en passant target square is specified after a double push of a pawn, no matter whether an en passant capture is really possible or not.
  
  That's pretty clear -- it's what you do.
  
  That's surprising to me. Following the footnotes, [there is a comment by the original author of FEN](http://www.talkchess.com/forum3/viewtopic.php?topic_view=threads&p=396838&t=37879#p396838) calling it a mistake, and in general there are a lot of people unhappy with the choice in the standard (it actually says to record *all* double pawn moves in the en passant field, even if there's no adjacent pawn -- e.g., after 1.e4).
  
  In the end it's a tradeoff between checking for the existence of a legal en passant move at the time of generating the FEN versus at the time of using it. In my opinion it would be nicest to check when generating, so what PyChess does. But what you do is what is written down in the standard and probably in common test sets.
  
  
  ---
  
  