10

I notice that when Stockfish has solved a position to mate it announces that checkmate is unavoidable in some number of moves so it's impossible to mistaken a position Stockfish has solved as a win for one player for a position that Stockfish has merely evaluated as being a position, for which one player has a huge advantage but not solved to the end yet.

On the other hand if Stockfish solves a position as being a draw with best play it just shows the position as being evaluated as 0.0 instead of announcing that it's a draw with best play, however an evaluation of 0.0 can also just indicate that Stockfish can't find an advantage for either player and doesn't necessarily mean it solved it to the end and found it to be a draw with best play from both players.

So my question is when Stockfish can solve a position as being a draw with best play from both players why doesn't the evaluation start saying "Draw" instead of "0.0" to show that the engine has solved it?

2
  • very related but I don't think it is a duplicate
    – Minot
    Commented Dec 11, 2022 at 16:06
  • "Keep playing until the end of the game". That's the rule, which speaks for itself. Commented Dec 13, 2022 at 15:38

5 Answers 5

7

Unless the Stockfish creators have documented this question, any answer will basically be based on speculation, more or less well-founded.

It should (theoretically) be possible to separate an evaluated draw and a draw due to endgame table hits: the first is an approximation to truth, based on the scoring function, and the second is truth (assuming suitable endgame tables).

However, this would require that the score of a search would have two components: the score itself, and a flag that says if that score is absolute or approximate. (EGTB mates would probably need to show a 'mate in n moves' and so be adjusted for each depth level of the score, while evaluated scores would not have the same relation to the level on which the score was evaluated, and so be handled differently.) This probably has additional effects on the code, when that composite score is used or passed on, and such effects are likely to have impact on search efficiency.

In general, engine makers focus on play engines rather than analysis engines, and so optimize their code in a particular direction, such as number of nodes per second. Stockfish seems to be a play engine, and so changes that improve non-play aspects are unlikely to be considered as important.

I suspect any definite answer is related to such considerations. But for a definitive answer, the Stockfish team should be the ultimate source, presumably through the forums indicated on their https://stockfishchess.org/get-involved/ web page.

1
  • 2
    +1 "separate an evaluated draw and a draw due to endgame table hits" It's not even as simple as it might sound like. If in a position White can choose between a move that goes into a position with approximate evaluation of -1.34 or a position with exact tablebase draw, the engine will show an evaluation of 0.00 for the position. That value comes from tablebases, but the evaluation of the position is still is an approximation because the approximated -1.34 might as well be a theoretically winning position, so the engine cannot make an exact claim that the game is a draw with best play.
    – JiK
    Commented Dec 12, 2022 at 10:33
4

Why doesn't Stockfish announce when it solved a position as a book draw similar to how it announces a forced mate?

Very simple. Checkmate ends the game. Once checkmate has been delivered there are no more moves in the game. That is a defined endpoint.

A book draw does not end the game. For instance there are several RKP vs RK which are book draws. If the player without the pawn knows how to draw the game, i.e. stop the opponent from queening the pawn, then they can stop their opponent from winning and the game will eventually be a draw.

There are various ways this can happen. The player with the pawn can realize that they are wasting their time and agree a draw. The position might repeat 3 times allowing the other player to claim a draw or there might be 50 moves without any captures or pawn moves when, again, the other player can claim a draw. However there is no clear point where the game ends. When exactly it ends depends of the choices of the players.

5
  • And even if someone would find such a feature useful (I do), someone would have to implement it first. Which is work :-) (It probably sits on a kilometers long nice-to-have list...) Commented Dec 11, 2022 at 18:49
  • 4
    I don't understand this answer, can't the same argument be used for a checkmate? Even if there's a forced checkmate with perfect play in X moves, the choices of the players might reduce or increase the number of moves (or even entirely miss the win). Commented Dec 12, 2022 at 15:28
  • @CarlaParla, the thing is though, you can't increase the number of moves. Assuming perfect play, X moves is the upper limit of the number of moves left. The game will be, at most, X moves from the end. There is a strong upper limit.
    – user70889
    Commented Dec 12, 2022 at 16:30
  • 1
    @user70889 Assuming perfect play there is still an upper limit on the number of moves left for a draw because of the threefold repetition rule. Perhaps the issue really is that the upper bound for a draw can be much larger? Commented Dec 12, 2022 at 17:30
  • Correct, chess is completely deterministic game. A mate is conclusive and forcing. These 6 moves force black to win for example. A draw is such a larger search space, and not always conclusive or forcing, so much harder to search. But an omniscent god/super computer, could look at the game and say ah yes, forced draw for white in 35 and forced draw for black in 28. BUt that is far beyond our computing atm.
    – user70889
    Commented Dec 12, 2022 at 19:15
0

Stockfish doesn't know what a book draw is, and it would be difficult to code because of endless variations.

For example, this position is a book draw:

[fen "3k4/1r2p3/r2pPp2/b1pP1Pp1/1pP3Pp/pP5P/P2K4/8 w - - 0 6"]

But it is also a book draw if the rook is on a7, a8, b8, c8, etc. How would you code it so that all of them are recognized as book draws? You can't realistically hard code all such positions.

Another issue with book draws is that they assume perfect play from the opponent. Sometimes the defense is difficult or even impossible for humans. The KR vs. KRB endgame is one such example. Here is another one from the most recent World Chess Championship.

[fen "4k3/8/8/4PR2/5P2/6NK/q7/8 w - - 0 1"]

This position with Black to play is also a book draw, as one can see from endgame tablebases, but it's complex enough that no human would be able to hold the Black position, and even Stockfish doesn't provide 0.00 eval when denied tablebases.

2
  • The question specifies "when Stockfish can solve a position as being a draw with best play from both players" so I don't think the first position is too relevant. If Stockfish can't solve it then it can't solve it. OP is asking about the cases when it can solve it.
    – D M
    Commented Dec 12, 2022 at 4:14
  • 3
    What the heck kind of answer is this? 1. Hard coding is not the only kind of coding. When it's not appropriate, use soft coding. 2. Obviously we have not solved chess, and so there are probably draws we don't know about. That shouldn't stop us from marking the draws we do know about. 3. If you remove part of my brain, I probably start evaluating positions differently, too. That doesn't mean the position's value is actually different. 4. Computers are inhuman. News at 11. That's the reason we have them, why would we intentionally bring them down to our level when using them as tools? Commented Dec 12, 2022 at 15:23
0

Chess engines have evaluations so that they can choose the best move. It assumes that whenever white has the move, it picks the move with the highest number, and black will choose the one with the lowest (at any point in the tree).

And the numerical value of a draw is the same as that of an equal position - 0.00. Because any better position is better than a draw, and a worse position is worse than a draw.

Now you could have two different "0" values. Perhaps (it'd make the engine a tiny bit slower, and thus weaker, but OK).

But the evaluation of the position is the result of comparing tens of thousands of such numbers -- the value of the current position, if white is to move, is the maximum of the values for each of the moves white can do; which is the minimum of the values of all the replies black has; which is the maximum of the values of all the second moves white could reply to those, et cetera.

Stockfish builds a whole tree of variations, at the end of each branch is a number. Many of them will be equal, and also many of them will be draws.

So what is the value if there are two moves, one evaluating to an equal position and one to a drawn position? There's no reasonable way to choose.

And as they're both 0.00 so it doesn't actually matter, and make the engine a bit slower, nobody does this.

This problem doesn't happen with checkmate -- no matter how good the evaluation, forced checkmate is better. And checkmate in 8 moves is better than in 9 moves.

0

Most forced outcomes are only forced in scenarios where both sides can be presumed to play optimally. In cases where Stockfish identifies and announces a forced mate in N for White, its announcement means that if Stockfish were given and allowed to keep control of White's pieces, then both sides would be guaranteed to play optimally so as to yield a score of 1-0:

  1. If Black resigns, the score would be 1-0 (no worse for Black than any other course of action).

  2. If Black runs out of time, the score would be 1-0 (again, no worse than any other course of action).

  3. If Black makes a move, either White will be able to checkamte, or make a move that forces a mate in at most N-1 moves (again, no worse...)

  4. If there's a power failure, that would violate the requirement that Stockfish be allowed to keep control of the White pieces, rendering that scenario irrelevant.

Unless there is a forced win by a side that's guaranteed to play optimally, however, the outcome of a match wouldn't really be forced. Even in the scenario where White has a king on a1, Black has a king on h8, and White has just moved Qg7+?? with no other pieces on the board, it would still be possible for either side to play sub-optimally by resigning at any point prior to Black either making the only legal move or running out of time [the latter resulting in a draw because no legal sequence of moves could result in checkmate].

4
  • I guess the "White runs out of time" scenario doesn't apply when it's already solved? Commented Dec 12, 2022 at 23:54
  • In a game between Stockfish and some outside entity, Stockfish has no way of knowing whether the opponent will make an optimal move, make a sub-optimal move,, run out of time, or resign, except that in the scenario where Stockfish has a forced win there would be no sub-optimal moves the opponent could make. What's significant is that the result will be 1-0 for Stockfish unless it is prevented from controlling its pieces.
    – supercat
    Commented Dec 13, 2022 at 16:03
  • I meant the scenario where Stockfish runs out of time. Then it would lose despite having a forced win. Commented Dec 16, 2022 at 19:00
  • @PaŭloEbermann: If Stockfish has the position in a tablebase, and is allowed to move its pieces without delay, it shouldn't run out of time. If something prevents Stockfish from moving its pieces instantly once it has located a position in the tablebase, that would fall under category #4 above.
    – supercat
    Commented Dec 16, 2022 at 20:22

Your Answer

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

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