6

My underlying question here is: What is depth?

I know depth is supposedly the number of half-moves or plies from the starting position that it has calculated, in at least one line. But I feel this explanation is not congruent with the result you're seeing here:

  1. I'd expect mate in 7 to be found at depth 14, but I understand it didn't search every line so okay it found it when it had already searched somewhere to depth 21. So far so good.
  2. But, now it finds M13, or mate in 25/26 ply, at depth 21, where it should be at at least depth 25. How?
  3. Furthermore, the depth keeps increasing after finding mate in 13 (ply 26). Why would it keep searching in sequences that are longer than the mate it already found? All subsequent analyses should stay below 26 ply right?

enter image description here

3
  • 1
    Please could you add the FEN of the position in plain text?
    – Rosie F
    Nov 7, 2021 at 11:27
  • 3
    The reason why the computer doesn't find the mate at depth 14 is because of pruning; it will not search all possible variatons 14 plies deep, but only look at the most "reasonable" ones according to its algorithm. As to why it finds the mate at depth 35 I guess it has to do with the computer increasing its depth by one step for each iteration of the algorithm, and it needs 35 such iterations before it actually finds the quickest mate. Since I'm no expert I'm waiting for someone who knows more about this to give a complete answer.
    – Scounged
    Nov 7, 2021 at 22:42
  • The short answer is that depth is an implementation detail
    – Sopel
    Nov 8, 2021 at 21:07

2 Answers 2

9

StockFish at its core uses alpha-beta pruning, as explained in this post. Alpha-beta pruning by itself always gives a correct move according to perfect play, assuming the final position evaluation heuristics are correct. However, SF uses not only alpha-beta pruning, but also many other pruning heuristics that may not be correct unlike alpha-beta pruning, but will greatly increase the final depth that the search can reach. That final depth is what SF means by "depth 35". It does not mean that SF searched every line to depth 35, because it would prune off the vast majority of lines. So if those pruning heuristics are incorrect, then SF may prune off the branch with the depth-7 forced checkmate sequence at lower final search depth.

In particular, the default setting of SF is not to find the fastest checkmate sequences alone but to find the best move in general, because it is much more computationally expensive to prove a checkmate sequence. Whenever SF says #k, it means it searched all the branches necessary to prove that a checkmate can be guaranteed in ≤k moves. But since SF is (wisely) designed not to spend all its time searching for the fastest checkmate sequence, it sometimes fails to see the optimal line because it checked other lines that looked more promising according to the sometimes incorrect heuristics.

That said, I don't know why you say it needed depth 35. Lichess analysis clearly shows that it already found the #7 in the default depth-20 search.

1
  • Aah, I hadn't considered the additional computation needed to prove something is a checkmate sequence. So the Bf1, Qb2+ sequence is very strong but it later proved that with Bb3, Nxh3+ mate was also inescapable and faster. My feeling remains that depth doesn't not mean what one would think it does.
    – Herman
    Oct 31, 2022 at 19:00
2

Because it is not thinking to depth 35 for all moves. These newer engines have multiple levels of thinking. When it says level 35, that means the level of deep thinking. It may only be thinking of 1 or 2 lines to ply 35. Then it works backwards in the tree to look for better moves at an earlier ply. Probably at depth 35 it found a theme which it could used earlier in the tree but had rejected at an earlier depth. Ultimately, when it says depth 35, it is really at that depth anyway. It uses 2 numbers like 24/35. That means that it is thinking of moves at ply 24 but it extends the lines of thinking to ply 35 to calculate the evaluation better. Still, it can only accept so many moves up to ply 24 in order to solve in a reasonable time so it has to sometimes backtrack later when it learns of a new move. For example, there could be a deflection involved. Deflections are not moves the engines normally consider. However, smart engines will discover the deflection later as it serves a purpose to prevent some later move from happening. It then works backwards to find the deflection. This is effectively how humans find deflections, also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.