10

Is there any chess engine that has an analysis mode that can show if a position is a forced draw by either side?

It is common for engines to output evaluations of 0.0 when they detect a draw. But an evaluation of 0.0 can mean many things. For example, assuming it is white to move, an evaluation of 0.0 can mean:

  • The game is certainly a draw regardless of how either player plays (e.g. insufficient material).
  • Both players can force a draw. Neither player can hope to win if their opponent plays perfectly.
  • No matter which move white plays, the computer is 100% sure that black can force a draw if he wishes to. White cannot hope to win if black plays perfectly. A draw is the most likely outcome, but a deeper search might show that black can force a win.
  • The computer is 100% sure that white can force a draw if he wishes to. Black cannot hope to win if white plays perfectly. A draw is the most likely outcome, but a deeper search might show that white can force a win.
  • The computer has not found a forced draw for either side, but the evaluation so far is exactly level. A draw is the most likely outcome, but a deeper search may later show an advantage for one side.

Just to give an example of when this might be useful, if white doesn't need to win and just wants to be as sure as possible of getting a draw then they might prefer to play a move with evaluation +0.0 and a known forced draw even though another move with a higher evaluation is available.

Another example is that if you need a win (i.e. a draw is just as bad as a loss) you might want to play a move with a slight negative evaluation to avoid giving your opponent the opportunity to force a draw. Even though this increases your chance of losing, it also increases your chance of winning.

Obviously there are positions where it is difficult or impossible to be sure whether a forced draw is available or not. But if the engine announces a forced draw then it must be possible to force a draw. False negatives are acceptable but there should be no false positives.

So in summary, I'd like to know for a specific position if one (or both players) have a forced draw available to them. Calculating the numerical evaluation of the position is not necessary, but if it also provides this at the same time, that's a bonus.

  • Isn't knowing this part of the point of the 6-piece endgame tables? – Tony Ennis Jun 3 '12 at 0:55
  • 2
    Table bases help, because then you know that a score of 0.0 is for certain a forced draw with optimal play. But I'd like the engine to tell me if it finds a forced draw from any arbitrary starting position, including (especially) when there are more than 6 pieces. For example, if white gets into a position where they can force perpetual check I'd like the engine to tell me that, even if it's not necessarily white's best move according to the evaluation function. – Mark Byers Jun 3 '12 at 16:37
  • I am curious when you'd actually be able to take advantage of this sort of calculation in practice. This would be a nice feature. In stockfish I use the UCI analysis "multiple variation" feature, which sorts the moves in order of their evaluation score. Forced draws show up in the listing pretty obviously when they're perpetual checks or stalemates, but sometimes it's less clear, and as you say, if you go deeper it might not be a draw. – Eve Freeman Jun 4 '12 at 15:08
  • 1
    But how forced is forced? I think that in many cases of so-called forced draws, the opponent can still deviate but at the cost of a clearly worse position. A position in which white can force either a draw or a full rook up wouldn't be a forced draw, limiting the usefulness. – RemcoGerlich Mar 26 '13 at 14:30
  • If white can force a draw instead of going a rook up then I would like to know that. – Mark Byers Mar 26 '13 at 14:33
8

The short answer to your question is no, there is not a chess engine that can reliably show if one side has a forced draw. For example, this locked position is quite clearly a draw to the human eye:

Locked position, hopeless draw

However, notice that the evaluation is 0.17, not 0.00. Houdini also give 0.05 - ever so slightly good for white. This is very important. This suggests that the evaluation of 0.00 is reserved by these programs for a specific reason, and indeed it is. Basically, even in an "equal" position, the computer will not ever say that the score is 0.00, instead it will give a minute edge to one or the other side.

So with that background, on to the specifics! First, if the game is just a draw due to the position (i.e. stalemate, insufficient material, etc.) most GUI's will pop up a message that says "Game Drawn", or something to that effect. That leaves the more complicated cases that you mentioned in your question. In order to cover most of those, I'll introduce another position. This is taken from Morphy-NN 1-0, New Orleans Blindfold Simul:

Morphy - NN 1-0, New Orleans Blindfold Simul

Notice that Morphy currently has mate in 6 starting with 18.b4+!. However, if Morphy somehow missed that this was mate, he still had a forced draw by repetition, which the computer quickly sees. By increasing the number of variations that the computer displays, it is possible to see that after white plays a move like 18.Qxc3+?, white can still force a draw, despite being down a rook and a piece. The evaluation of 0.00 again tips us off that this is a special position in that the computer can calculate a perpetual check. If the moves 18.Qxc3+? Kxd5 are made on the board, then the evaluation will be 0.00, indicating that white's best continuation is to force a draw. Failure to do this will lead to loss of the game with best play.


So to summarize, no existing engine can say with exact certainty that a position is a draw. However, the evaluation of 0.00 is special, and if that shows up as either the main score, or the score for a variation, that means that a draw is probably being forced in that specific line. The easiest way to check is playfully called "spacebar analysis" - when the user hits the spacebar over and over again to force the computer to play the top recommended move. Eventually you will get to a position that is obvious to a human as well as the machine.


And finally, to address your point about "contempt"

Another example is that if you need a win (i.e. a draw is just as bad as a loss) you might want to play a move with a slight negative evaluation to avoid giving your opponent the opportunity to force a draw. Even though this increases your chance of losing, it also increases your chance of winning.

This is quite simply referred to as contempt among chess programmers. Most engines will allow you to set the level of contempt in the settings. A positive contempt setting (100 is usually a reasonable level for analysis) will tell the engine to try fairly hard (a pawn's worth) to avoid a draw. A negative setting will cause the engine to seek a forced draw (i.e. insufficient material, stalemate, or perpetual).

  • This is roughly the same idea as in Wes Freeman's comment to the question, and just as what he describes requires some human input - "Forced draws show up in the listing pretty obviously [sometimes], but sometimes it's less clear" - your answer has the human contributing "spacebar analysis." This is why I suggest tweaking the evaluation function in my answer; we're making it so that the engine itself actually seeks out forced draws and lets us know when they are conclusively present. That seems to be the only substantive difference between the approaches. – ETD Jun 12 '12 at 16:32
  • @EdDean I agree. The hardest draws to find are the ones where an endgame can't be won, but one side can press for the win forever. Separately, changing the engines' eval function would be one approach, but most likely not something that can be done in on a reasonable timescale. It is possible to play around with contempt settings currently, but that does not do the same thing as re-programming an engine as you suggest either. The human-editable settings are fairly limited on current engines. – Andrew Jun 12 '12 at 16:37
  • That contempt setting is neat--hadn't noticed it. – Eve Freeman Jun 12 '12 at 20:54
  • 2
    By the way, I don't think 0.00 is always indicative of a forced draw, which you seemed to imply. I see it occasionally even early in openings--I suppose it just means that given the current position and material, it is likely even, and the evaluation happens to be 0.00. – Eve Freeman Jun 12 '12 at 23:42
  • 3
    Interesting. In stockfish it is definitely not. Just analyzing the opening position for a few seconds will return plenty of 0.00 scores. – Eve Freeman Jun 12 '12 at 23:48
4

Just as engines can, at certain points, see a forced mate some number of moves away, because there are forcing enough lines that the engine can see everything perfectly in the remaining depth until mate, there are also junctures in chess games that would allow an engine to see a forced draw for the same reason of being able to completely survey the limited possibilities in play.

Moreover, it would be easy to tweak an engine's evaluation function in order to make it seek out and prefer moves that lead to such forced draws: just as achieving mate is typically given some enormous value that dwarfs all other numerical factors that the engine's evaluation algorithm considers in order to guide the engine's play toward the ultimate objective, one could instead give such an enormous numerical value to achieving one of the sorts of draws I have in mind.

For instance, automatically evaluate any position in which the opponent has insufficient material to mate as +1000000. Then, if the engine ever finds itself with the option of forcing off that much material of the opponent's, it will let you know. Also, tweak the evaluation algorithm to evaluate any three-fold repetition as +1000000 instead of the usual 0. Then, if there is a forcible repetition (as in a perpetual check scenario), the engine will love it and let you know about it. Similarly, give +1000000 if one can forcibly reach a tablebase draw.

You could also ensure that the engine will give these valuations only when there is complete certainty that the draws really are forcible (because the tree between here and there has been able to be fully checked), just as with an engine not announcing mate unless it is sure. Thus, you won't get any false positives, though there will of course be plenty of false negatives, which you sensibly/necessarily allow in your question.

  • I don't think that any engine will work like this "out of the box" due to contempt factors and the way that they prune. Basically, if a draw was found, any line that won material would be excluded. So for example checking the king would be preferable to capturing a free rook. I'm considering posting a longer answer because there are ways to use current engines to do this, but I don't want to give away too many preparation secrets. ;) – Andrew Jun 12 '12 at 5:49
  • No engine will work the way I described "out of the box," it's true, as they are designed to seek wins; for the same reason, you'd have to do some tweaking to make a normal engine play, say, suicide chess. I already have us modifying the evaluation function; any contempt factor can be tweaked/disabled along with what I suggested if need be, yes? My main point is that I think existing engines can be re-purposed (in a reasonably straightforward way) to function as Mark wants. So, at the moment at least, I still see this as a way to "use current engines." My mind can always be changed though. :) – ETD Jun 12 '12 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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