Answers.Body: <p>TLDR: Stockfish analyzed to quiet positions resulting from the position you posted and then statically evaluated them to be at least +3.15 evaluation for white assuming best play from black. I think this is counterintuitive to you because you stopped before getting to quiet positions and statically evaluated too early!</p>
  <p><strong>Explaining How Engines Work</strong></p>
  <p>I'll take the approach of explaining a bit about how the engine works internally, how that differs from the analysis you provided in your post, and how those things taken together explain why it chooses this line and why it seems counterintuitive to you. Stockfish (and every engine I know of) does two main things: 1) search, where it plays out possible lines/variations, and 2) evaluation, where it assigns a numerical value to the position in a search. The evaluation method used is called &quot;static evaluation&quot;, which is basically a mapping from the board state to a score <em>without regard</em> for what the next move or moves could be, or even whose turn it is. It involves things like counting material and also assigning numerical values to positional features like how many squares your pieces can go to and a vast array of complex material/square patterns. So for example if we have 1. e4 d5 2. exd5 * and the engine is asked to do a static evaluation in that position, it would see that white is a pawn up, and <a href="https://hxim.github.io/Stockfish-Evaluation-Guide/?p=rnbqkbnr%2Fppp1pppp%2F8%2F3P4%2F8%2F8%2FPPPP1PPP%2FRNBQKBNR%20b%20KQkq%20-%200%202" rel="noreferrer">assign an evaluation</a> of about +1 for white; a version of this static evaluation function is available online and that is what I have linked above. <em>However</em>, we know that +1 is incorrect in this position, because 2...Qxd5 is coming, after which material is equal again. So, it is not enough for the engine to statically evaluate the position; in fact it must choose the right moment to statically evaluate the position, otherwise it will make these kinds of mistakes. So when is a good time to statically evaluate, and when is a bad time? In human play we call the positions in which static evaluations are reasonable as &quot;quiet&quot; positions. In other words, when all tension is removed, when all pending captures are completed, when all tactical or forcing sequences are resolved, we arrive at a quiet position, and <em>that's</em> when you should statically evaluate the position. When the engine does this, it is called quiescence search.</p>
  <p>You stopped at 27. Rxd7+ and did your own form of static evaluation, which was to count material. However, the engine realized that this is not a quiet position; indeed, there are still forcing tactical lines to concretely calculate here that involve checks, captures, threats, forks, etc., and other answers have provided that analysis. In every case, after the engine explored all those lines until it got to quiet positions, only then did it statically evaluate and decide that white is better by about +3 with best play from black.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-04T13:20:47.637Z
Answers.Text: @JMuzhen: You may want to also read [this](https://chess.stackexchange.com/a/37381/9192) and [this](https://chess.stackexchange.com/a/29842/9192).
Answers.UserDisplayName: user21820
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-03T19:26:08.240Z
Answers.LastActivityDate: 2022-10-03T19:26:08.240Z
Answers.UserDisplayName: rajb245
Answers.Body: <p>Since the answer by D M, while correct, gives an incomplete analysis of the position, I lengthen the variants somewhat such that even a beginner will see there is no escape for Black. Only the last two variants make sense for Black.</p>
  <p>27...Kg8 28.Nxe6</p>
  <ul>
  <li>a) any: Nxf8, which even protects the Rd7 after 28...Rh7 (this is so bitter)</li>
  <li>b) any Q: Rg7#</li>
  <li>c) 28...Qf7 29.Rd8+! Kh7 30.Ng5+ followed by Nxf7, again protecting the wR. White is a ton of pawns up.</li>
  </ul>
  <p>27...Kg6 28.Nxe6</p>
  <ul>
  <li><p>a) any: Nxf8</p>
  </li>
  <li><p>b) any Q: Rg7+ and Nf4#</p>
  </li>
  <li><p>c) 28...Qg8 29.Nd5!! and Black can only choose between a fork on e7 if Nh6~ protects against Ndf4# or a fork on f4 after 29....Qxe6. White gets all material back and is a ton of pawns up.</p>
  </li>
  <li><p>d) 28...Qf7 29.Nf4+ and now</p>
  </li>
  <li><p>d1) 28...Kg5 29.h4+ Kg4 30.Rxf7 Nxf7 31.Kg2. Now 31...any 32.Nd5 or 31...Rc8 32.e6 Ne5 33.Nd1 Rxc2+ 34.Nf2+ costs Black at least the exchange so White, you guessed it, is a ton of pawns up.</p>
  </li>
  <li><p>d2) 28...Kg7 29.e6! Qxd7 30.exd7. Now the fork on e6 forces Black to 30...Nf7, otherwise the exchange is gone and White...you know the deal. :-) Or 30...Kf7, which, as 30...Nf7, is answered by 31.Ncd5. Now you must play out a lot of variants where Black tries to gang up on the Pd7 with K+R+N. Spoiler: Fail, due to more random forks. White corks a N to c5 or e5 and protects it in time with K or P. (Here the analysis might be extended until noone can deny Black can't get the Pd7 without giving the exchange, so Black is tied up forever and White wins with youknowwhat. OTB I probably would have calculated until there and evaluated it as &quot;good for White&quot; - except that I can't calculate or find Nd5!!)</p>
  </li>
  <li><p>d3) 28...Kh7 29.e6 Qxd7 30.exd7 e.g. Rd8 31.Ne6 Rxd7 32.Nf8+, Black throws the board against the wall and screams to the sky &quot;I %&amp;$§ING HATE KNIGHTS!!!&quot;</p>
  </li>
  </ul>
  <p>Hooboy. This could have been a game of mine, my knights tend to give the opponent knightmares...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-02T17:31:46.120Z
Answers.LastActivityDate: 2022-10-03T17:10:03.967Z
Answers.LastEditDate: 2022-10-03T17:10:03.967Z
Answers.UserDisplayName: Hauke Reddmann
Answers.Body: <p>After 27.Rxd7+ there's only 5 possible responses.</p>
  <ul>
  <li><p>27...Qe7 is plainly bad due to Rxe7+.</p>
  </li>
  <li><p>After 27...Qf7 Black is obviously losing the queen, but White can do better than taking it right away. 28.Nxe6+ takes advantage of the pin, gaining the knight <em>before</em> taking the queen with the rook. (And then after 28...Kg6 - White will fork king and queen with the knight if Black plays anything else - White can throw in 29.Nf4+ if they want, which defends h3, blocks Black's pawn on f5, and supports an e6 push.)</p>
  </li>
  <li><p>After 27...Nf7, 28.Nxe6+ forks the queen.</p>
  </li>
  <li><p>After 27...Kg8, 28.Nxe6 threatens the queen and also threatens Rg7# if the queen stops covering g7. (Note that the knight on e6 also covers c5 to prevent the queen from escaping with a check.)</p>
  </li>
  <li><p>Similarly, after 27...Kg6, 28.Nxe6, White threatens Rg7+ Kh5 Nf4# if Black were to retreat the queen.</p>
  </li>
  </ul>
  <p>So, Black doesn't actually get to keep that queen. White then hopes to win the much-simplified position using all those pawns.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-03T09:17:21.067Z
Answers.Text: In the Qf7 variation, why would 28.Nxe6+ be better? Black can do 28...Kf7 to protect the queen so white rook will be captured if it captured black queen?
Answers.UserDisplayName: justhalf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-03T09:27:30.367Z
Answers.Text: How is Black playing Kf7 if they play Qf7?
Answers.UserDisplayName: D M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-04T06:35:46.123Z
Answers.Text: Ooh, I switched the first and second variation up, my bad. So white rook is going down anyway then. Noted.
Answers.UserDisplayName: justhalf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-02T13:37:56.727Z
Answers.LastActivityDate: 2022-10-02T13:37:56.727Z
Answers.UserDisplayName: D M
Body: <p>In this position, why does Stockfish suggest the move 1. Qxa6?
  Also, after 25. ...bxa6, Stockfish also suggests 26. Rd7+, which is followed by 26. ...Bxd7 and 27. Rxd7+.
  White would just have traded a queen and rook for a rook and bishop. In this position, however, Stockfish still gives an evaluation of +3.15.</p>
  <p>I find it difficult to accept that this is the best move for White.</p>
  <pre><code>[Title &quot;Current position&quot;]
  [FEN &quot;2b2q1r/1p4k1/r3n2n/p2RPpN1/P7/2N3PP/1PP1Q3/3R2K1 w - -&quot;]
  [startply &quot;48&quot;]
  
  1. d4 a5 2. Nf3 h5 3. e4 d6 4. Bc4 e6 5. Nc3 Be7 6. O-O c6 7. a4 Na6 8. Qe2 Kf8 9. Rd1 d5 10. Bb3 g6 11. Bf4 Kg7 12. Be5+ f6 13. Bf4 g5 14. Be3 h4 15. h3 Nh6 16. e5 f5 17. g3 hxg3 18. fxg3 c5 19. dxc5 Nxc5 20. Bxd5 exd5 21. Rxd5 Qf8 22. Bxg5 Bxg5 23. Nxg5 Ra6 24. Rad1 Ne6 25. Qxa6 bxa6 26. Rd7+ Bxd7 27. Rxd7+ 
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-04T08:41:54.617Z
Comments.Text: Another comment: White has three pawns for a piece, so if White's attack fizzles out, imminent losing danger. Thus, Qxa6 is not only (accidentally!) a good move, it's possibly the only one. Carpe diem, as the Roman says.
Comments.UserDisplayName: Hauke Reddmann
Tags: <analysis><stockfish>
Title: Why does Stockfish suggest this move (25. Qxa6?)
ThreadText: # Why does Stockfish suggest this move (25. Qxa6?)
  
  (Asked by: username_0 on 2022-10-02)
  
  In this position, why does Stockfish suggest the move 1. Qxa6?
  Also, after 25. ...bxa6, Stockfish also suggests 26. Rd7+, which is followed by 26. ...Bxd7 and 27. Rxd7+.
  White would just have traded a queen and rook for a rook and bishop. In this position, however, Stockfish still gives an evaluation of +3.15.
  
  I find it difficult to accept that this is the best move for White.
  
  ```
  [Title "Current position"]
  [FEN "2b2q1r/1p4k1/r3n2n/p2RPpN1/P7/2N3PP/1PP1Q3/3R2K1 w - -"]
  [startply "48"]
  
  1. d4 a5 2. Nf3 h5 3. e4 d6 4. Bc4 e6 5. Nc3 Be7 6. O-O c6 7. a4 Na6 8. Qe2 Kf8 9. Rd1 d5 10. Bb3 g6 11. Bf4 Kg7 12. Be5+ f6 13. Bf4 g5 14. Be3 h4 15. h3 Nh6 16. e5 f5 17. g3 hxg3 18. fxg3 c5 19. dxc5 Nxc5 20. Bxd5 exd5 21. Rxd5 Qf8 22. Bxg5 Bxg5 23. Nxg5 Ra6 24. Rad1 Ne6 25. Qxa6 bxa6 26. Rd7+ Bxd7 27. Rxd7+ 
  
  ```
  
  **Tags:** analysis, stockfish
  
  > **Comments:**
  > **username_1**: Another comment: White has three pawns for a piece, so if White's attack fizzles out, imminent losing danger. Thus, Qxa6 is not only (accidentally!) a good move, it's possibly the only one. Carpe diem, as the Roman says.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2022-10-02. Score: 17 | Accepted answer
  
  After 27.Rxd7+ there's only 5 possible responses.
  
  * 27...Qe7 is plainly bad due to Rxe7+.
  * After 27...Qf7 Black is obviously losing the queen, but White can do better than taking it right away. 28.Nxe6+ takes advantage of the pin, gaining the knight *before* taking the queen with the rook. (And then after 28...Kg6 - White will fork king and queen with the knight if Black plays anything else - White can throw in 29.Nf4+ if they want, which defends h3, blocks Black's pawn on f5, and supports an e6 push.)
  * After 27...Nf7, 28.Nxe6+ forks the queen.
  * After 27...Kg8, 28.Nxe6 threatens the queen and also threatens Rg7# if the queen stops covering g7. (Note that the knight on e6 also covers c5 to prevent the queen from escaping with a check.)
  * Similarly, after 27...Kg6, 28.Nxe6, White threatens Rg7+ Kh5 Nf4# if Black were to retreat the queen.
  
  So, Black doesn't actually get to keep that queen. White then hopes to win the much-simplified position using all those pawns.
  
  > **Comments:**
  > **username_5**: In the Qf7 variation, why would 28.Nxe6+ be better? Black can do 28...Kf7 to protect the queen so white rook will be captured if it captured black queen?  
  > **username_4**: How is Black playing Kf7 if they play Qf7?  
  > **username_5**: Ooh, I switched the first and second variation up, my bad. So white rook is going down anyway then. Noted.  
  
  ---
  
  ### Answer by username_2 on 2022-10-03. Score: 9
  
  TLDR: Stockfish analyzed to quiet positions resulting from the position you posted and then statically evaluated them to be at least +3.15 evaluation for white assuming best play from black. I think this is counterintuitive to you because you stopped before getting to quiet positions and statically evaluated too early!
  
  **Explaining How Engines Work**
  
  I'll take the approach of explaining a bit about how the engine works internally, how that differs from the analysis you provided in your post, and how those things taken together explain why it chooses this line and why it seems counterintuitive to you. Stockfish (and every engine I know of) does two main things: 1) search, where it plays out possible lines/variations, and 2) evaluation, where it assigns a numerical value to the position in a search. The evaluation method used is called "static evaluation", which is basically a mapping from the board state to a score *without regard* for what the next move or moves could be, or even whose turn it is. It involves things like counting material and also assigning numerical values to positional features like how many squares your pieces can go to and a vast array of complex material/square patterns. So for example if we have 1. e4 d5 2. exd5 \* and the engine is asked to do a static evaluation in that position, it would see that white is a pawn up, and [assign an evaluation](https://hxim.github.io/Stockfish-Evaluation-Guide/?p=rnbqkbnr%2Fppp1pppp%2F8%2F3P4%2F8%2F8%2FPPPP1PPP%2FRNBQKBNR%20b%20KQkq%20-%200%202) of about +1 for white; a version of this static evaluation function is available online and that is what I have linked above. *However*, we know that +1 is incorrect in this position, because 2...Qxd5 is coming, after which material is equal again. So, it is not enough for the engine to statically evaluate the position; in fact it must choose the right moment to statically evaluate the position, otherwise it will make these kinds of mistakes. So when is a good time to statically evaluate, and when is a bad time? In human play we call the positions in which static evaluations are reasonable as "quiet" positions. In other words, when all tension is removed, when all pending captures are completed, when all tactical or forcing sequences are resolved, we arrive at a quiet position, and *that's* when you should statically evaluate the position. When the engine does this, it is called quiescence search.
  
  You stopped at 27. Rxd7+ and did your own form of static evaluation, which was to count material. However, the engine realized that this is not a quiet position; indeed, there are still forcing tactical lines to concretely calculate here that involve checks, captures, threats, forks, etc., and other answers have provided that analysis. In every case, after the engine explored all those lines until it got to quiet positions, only then did it statically evaluate and decide that white is better by about +3 with best play from black.
  
  > **Comments:**
  > **username_3**: @username_0: You may want to also read [this](https://chess.stackexchange.com/a/37381/9192) and [this](https://chess.stackexchange.com/a/29842/9192).  
  
  ---
  
  ### Answer by username_1 on 2022-10-02. Score: 4
  
  Since the answer by D M, while correct, gives an incomplete analysis of the position, I lengthen the variants somewhat such that even a beginner will see there is no escape for Black. Only the last two variants make sense for Black.
  
  27...Kg8 28.Nxe6
  
  * a) any: Nxf8, which even protects the Rd7 after 28...Rh7 (this is so bitter)
  * b) any Q: Rg7#
  * c) 28...Qf7 29.Rd8+! Kh7 30.Ng5+ followed by Nxf7, again protecting the wR. White is a ton of pawns up.
  
  27...Kg6 28.Nxe6
  
  * a) any: Nxf8
  * b) any Q: Rg7+ and Nf4#
  * c) 28...Qg8 29.Nd5!! and Black can only choose between a fork on e7 if Nh6~ protects against Ndf4# or a fork on f4 after 29....Qxe6. White gets all material back and is a ton of pawns up.
  * d) 28...Qf7 29.Nf4+ and now
  * d1) 28...Kg5 29.h4+ Kg4 30.Rxf7 Nxf7 31.Kg2. Now 31...any 32.Nd5 or 31...Rc8 32.e6 Ne5 33.Nd1 Rxc2+ 34.Nf2+ costs Black at least the exchange so White, you guessed it, is a ton of pawns up.
  * d2) 28...Kg7 29.e6! Qxd7 30.exd7. Now the fork on e6 forces Black to 30...Nf7, otherwise the exchange is gone and White...you know the deal. :-) Or 30...Kf7, which, as 30...Nf7, is answered by 31.Ncd5. Now you must play out a lot of variants where Black tries to gang up on the Pd7 with K+R+N. Spoiler: Fail, due to more random forks. White corks a N to c5 or e5 and protects it in time with K or P. (Here the analysis might be extended until noone can deny Black can't get the Pd7 without giving the exchange, so Black is tied up forever and White wins with youknowwhat. OTB I probably would have calculated until there and evaluated it as "good for White" - except that I can't calculate or find Nd5!!)
  * d3) 28...Kh7 29.e6 Qxd7 30.exd7 e.g. Rd8 31.Ne6 Rxd7 32.Nf8+, Black throws the board against the wall and screams to the sky "I %&$§ING HATE KNIGHTS!!!"
  
  Hooboy. This could have been a game of mine, my knights tend to give the opponent knightmares...
  
  
  ---
  
  