Answers.Body: <p>you are missing an en passant capture</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-31T12:32:46.253Z
Answers.Text: Oh yes, that's right. When I was testing this, I was using Lichess Board editor, and forgot to add the en passant square to the fen, so stockfish didn't count it either. I didn't see it when I counted by hand because I missed the fact that the black pawn would block the check. Thank you very much!
Answers.UserDisplayName: Ilan 
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-31T12:24:04.577Z
Answers.LastActivityDate: 2024-01-31T12:24:04.577Z
Answers.UserDisplayName: r5m8
Body: <p>I am writing a chess engine, and I am comparing my move generation results with Stockfish. I am currently stumped by this result.</p>
  <p>In this position <code>8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - -</code> from <a href="https://www.chessprogramming.org/Perft_Results" rel="nofollow noreferrer">https://www.chessprogramming.org/Perft_Results</a>, at depth 6, my engine has <strong>11030061</strong> moves while Stockfish gets <strong>11030083</strong>. I follow the discrepancies in nodes visited from each root position until I reach this position <code>8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - - 0 1</code>. At depth 2 Stockfish finds <strong>256</strong> positions, I find <strong>255</strong>. The discrepancy is at g2g4. Stockfish finds <strong>16</strong> nodes, I find <strong>15</strong>. When I make g2g4 then run Stockfish on this new position, it finds 15 moves, the same as my engine. Counting the moves in <code>8/2p5/8/KP1p2kr/5pP1/8/4P3/6R1 b - - 0 1</code> by hand, it seems to me that there should be 15.</p>
  <p>Why does Stockfish find a 16th move from g2g4 at depth 2 in <code>8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - - 0 1</code> and yet when g2g4 is made, it finds 15 moves for black?</p>
  
Tags: <programming>
Title: Confusing about perft test on Stockfish
ThreadText: # Confusing about perft test on Stockfish
  
  (Asked by: username_0 on 2024-01-31)
  
  I am writing a chess engine, and I am comparing my move generation results with Stockfish. I am currently stumped by this result.
  
  In this position `8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - -` from <https://www.chessprogramming.org/Perft_Results>, at depth 6, my engine has **11030061** moves while Stockfish gets **11030083**. I follow the discrepancies in nodes visited from each root position until I reach this position `8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - - 0 1`. At depth 2 Stockfish finds **256** positions, I find **255**. The discrepancy is at g2g4. Stockfish finds **16** nodes, I find **15**. When I make g2g4 then run Stockfish on this new position, it finds 15 moves, the same as my engine. Counting the moves in `8/2p5/8/KP1p2kr/5pP1/8/4P3/6R1 b - - 0 1` by hand, it seems to me that there should be 15.
  
  Why does Stockfish find a 16th move from g2g4 at depth 2 in `8/2p5/8/KP1p2kr/5p2/8/4P1P1/6R1 w - - 0 1` and yet when g2g4 is made, it finds 15 moves for black?
  
  **Tags:** programming
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-31. Score: 1
  
  you are missing an en passant capture
  
  > **Comments:**
  > **username_0**: Oh yes, that's right. When I was testing this, I was using Lichess Board editor, and forgot to add the en passant square to the fen, so stockfish didn't count it either. I didn't see it when I counted by hand because I missed the fact that the black pawn would block the check. Thank you very much!  
  
  ---
  
  