Answers.Body: <p>For anyone who stumbles across this wondering the same thing, I received an answer to my question <a href="https://www.reddit.com/r/ComputerChess/comments/p6k3jl/techniques_used_for_stockfish_engine_selectivity/" rel="nofollow noreferrer">here</a>. This post is thus a courtesy of <a href="https://www.reddit.com/user/__Durandal__/" rel="nofollow noreferrer">u/__Durandal__</a> and <a href="https://www.reddit.com/user/IMJorose/" rel="nofollow noreferrer">IMJorose</a>. Though I can't do justice to their write-ups and highly recommend them, in case it somehow goes down, I'll summarize the gist here.</p>
  <p>The reduction techniques in Stockfish are <em>not</em> limited to just one or two ply—late move reductions, for example, are calculated based on the number of moves already searched and the current depth. In the current implementation:</p>
  <blockquote>
  <p>If a position has 40 moves in it and is searched at depth 16, the reduction applied is five plies.</p>
  </blockquote>
  <p>Furthermore, any potentially-unsafe pruning techniques (i.e. avoiding entire part of the tree) have a depth cap at which they stop operating. These two phenomena explain what I was seeing.</p>
  <p>Notably, given infinite time, Stockfish will still converge to the minimax solution: reduction techniques become inconsequential at infinite depth and depth caps mean that nothing will be overlooked via pruning.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-23T04:27:14.930Z
Answers.LastActivityDate: 2021-08-23T04:27:14.930Z
Answers.UserDisplayName: iRove
Answers.Body: <p>I am not an expert on this, but I think one can get some insight into this by examining how Leela's Monte Carlo Tree Search works. Leela's neural network gives 1) a win percentage for that position, and 2) a list of candidate moves to consider, each with a probability. Leela then uses that probability in its searches. For example, if the neural network is 99% confident that a particular move is correct, then Leela will spend 99% (?) of its time looking at that move.</p>
  <p><em>However</em>, it will also eventually look at the remaining 1%. It will de-emphasize the other moves, and it will spend less time looking at those moves, but it will do so eventually.</p>
  <p>I think that's what you're seeing here. The key first move gives away a Queen for no apparent compensation, so Stockfish de-emphasizes it. However, after it has searched the mainlines to very high depth (d=36), it goes back and looks at the moves it earlier de-emphasized. It finds that 1.Qh5+ is better, and this line becomes promoted to the new principal variation.</p>
  <p>I do not know the technical details, however.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-18T03:39:23.147Z
Answers.Text: Thanks for taking a stab! From what I understand, you're absolutely correct. This explains how Leela might respond to the puzzle. I guess I'm looking for the alpha/beta search equivalent of this monte carlo tree search characteristic. It's almost like we get there with late move reductions, but I didn't think they could go as far as 20 ply.
Answers.UserDisplayName: iRove
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-18T02:09:03.500Z
Answers.LastActivityDate: 2021-08-18T02:09:03.500Z
Answers.UserDisplayName: Allure
Body: <p>Example puzzle (I'm sure there are numerous that fit this bill):</p>
  <pre><code>[FEN &quot;rnbq3r/pppp4/3b1pkp/5p2/2BP4/4P3/PPP2PPP/RN1QK2R w KQ - 0 1&quot;]
  [Site &quot;Earth&quot;]
  [White &quot;&quot;]
  
  1. Qh5+ Kxh5 2. Bf7+ Kh4 3. Nd2 Bb4 4. c3 f4 5. Nf3+ Kg4 6. e4 Bxc3+ 7. bxc3 f5 8. h3#
  </code></pre>
  <p>I've found a 8 move checkmate that takes Stockfish a depth of 36 ply to solve. Since the checkmate is only 16 ply deep in the game search tree, what <em>specific</em> mechanisms cause the engine to take <em>20 ply</em> longer to find the solution?</p>
  <p>I understand that the high level answer is <a href="https://www.chessprogramming.org/Selectivity" rel="nofollow noreferrer">engine selectivity</a>. However, my understanding is that Stockfish's forward pruning tended to be pretty safe (such as <a href="https://www.chessprogramming.org/Null_Move_Pruning" rel="nofollow noreferrer">null move pruning</a>). Plus, if the solution were being forward pruned, <em>wouldn't it keep being pruned even at later depths</em>?</p>
  <p>I also thought that <a href="https://www.chessprogramming.org/Reductions" rel="nofollow noreferrer">reductions</a> such as <a href="https://www.chessprogramming.org/Late_Move_Reductions#Reduction_Depth" rel="nofollow noreferrer">late move reductions</a> only really reduce the search depth by a one or a few ply, not 20!</p>
  <p>(The winning move is a check, so it shouldn't be reduced by something like late move reduction anyways.)</p>
  <p>What gives?</p>
  <p>(<a href="https://www.reddit.com/r/ComputerChess/comments/p6k3jl/techniques_used_for_stockfish_engine_selectivity/" rel="nofollow noreferrer">Crossposted</a>...will be sure to update if anything comes of it)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-17T23:25:14.250Z
Comments.Text: Enumerating the exact set of techniques in action here might be too difficult, but I'd really appreciate if anyone could give me a general idea of where my thought process might be going wrong.
Comments.UserDisplayName: iRove
Tags: <engines><stockfish><programming><evaluation>
Title: Techniques used for Stockfish engine selectivity
ThreadText: # Techniques used for Stockfish engine selectivity
  
  (Asked by: username_0 on 2021-08-16)
  
  Example puzzle (I'm sure there are numerous that fit this bill):
  [FEN "rnbq3r/pppp4/3b1pkp/5p2/2BP4/4P3/PPP2PPP/RN1QK2R w KQ - 0 1"]
  [Site "Earth"]
  [White ""]
  
  1. Qh5+ Kxh5 2. Bf7+ Kh4 3. Nd2 Bb4 4. c3 f4 5. Nf3+ Kg4 6. e4 Bxc3+ 7. bxc3 f5 8. h3#
  
  I've found a 8 move checkmate that takes Stockfish a depth of 36 ply to solve. Since the checkmate is only 16 ply deep in the game search tree, what specific mechanisms cause the engine to take 20 ply longer to find the solution?
  I understand that the high level answer is engine selectivity. However, my understanding is that Stockfish's forward pruning tended to be pretty safe (such as null move pruning). Plus, if the solution were being forward pruned, wouldn't it keep being pruned even at later depths?
  I also thought that reductions such as late move reductions only really reduce the search depth by a one or a few ply, not 20!
  (The winning move is a check, so it shouldn't be reduced by something like late move reduction anyways.)
  What gives?
  (Crossposted...will be sure to update if anything comes of it)
  
  **Tags:** engines, stockfish, programming, evaluation
  
  > **Comments:**
  > **username_0**: Enumerating the exact set of techniques in action here might be too difficult, but I'd really appreciate if anyone could give me a general idea of where my thought process might be going wrong.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-08-23. Score: 2
  
  For anyone who stumbles across this wondering the same thing, I received an answer to my question [here](https://www.reddit.com/r/ComputerChess/comments/p6k3jl/techniques_used_for_stockfish_engine_selectivity/). This post is thus a courtesy of [u/\_\_Durandal\_\_](https://www.reddit.com/user/__Durandal__/) and [IMJorose](https://www.reddit.com/user/IMJorose/). Though I can't do justice to their write-ups and highly recommend them, in case it somehow goes down, I'll summarize the gist here.
  
  The reduction techniques in Stockfish are *not* limited to just one or two ply—late move reductions, for example, are calculated based on the number of moves already searched and the current depth. In the current implementation:
  
  > If a position has 40 moves in it and is searched at depth 16, the reduction applied is five plies.
  
  Furthermore, any potentially-unsafe pruning techniques (i.e. avoiding entire part of the tree) have a depth cap at which they stop operating. These two phenomena explain what I was seeing.
  
  Notably, given infinite time, Stockfish will still converge to the minimax solution: reduction techniques become inconsequential at infinite depth and depth caps mean that nothing will be overlooked via pruning.
  
  
  ---
  
  ### Answer by username_1 on 2021-08-18. Score: 1
  
  I am not an expert on this, but I think one can get some insight into this by examining how Leela's Monte Carlo Tree Search works. Leela's neural network gives 1) a win percentage for that position, and 2) a list of candidate moves to consider, each with a probability. Leela then uses that probability in its searches. For example, if the neural network is 99% confident that a particular move is correct, then Leela will spend 99% (?) of its time looking at that move.
  
  *However*, it will also eventually look at the remaining 1%. It will de-emphasize the other moves, and it will spend less time looking at those moves, but it will do so eventually.
  
  I think that's what you're seeing here. The key first move gives away a Queen for no apparent compensation, so Stockfish de-emphasizes it. However, after it has searched the mainlines to very high depth (d=36), it goes back and looks at the moves it earlier de-emphasized. It finds that 1.Qh5+ is better, and this line becomes promoted to the new principal variation.
  
  I do not know the technical details, however.
  
  > **Comments:**
  > **username_0**: Thanks for taking a stab! From what I understand, you're absolutely correct. This explains how Leela might respond to the puzzle. I guess I'm looking for the alpha/beta search equivalent of this monte carlo tree search characteristic. It's almost like we get there with late move reductions, but I didn't think they could go as far as 20 ply.  
  
  ---
  
  