Answers.Body: <p>Unlike playing with people, an engine will make the best move it can find, assuming perfect play on the part of the opponent.  Engines don't play &quot;hope chess&quot; - they don't assume (or hope) that the opponent will make a mistake.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T00:45:03.857Z
Answers.Text: Isn't the concept of contempt in chess engines exactly that they don't assume their opponent is perfect?
Answers.UserDisplayName: Joseph Sible-Reinstate Monica
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T01:53:09.550Z
Answers.Text: @JosephSible-ReinstateMonica You'd need a lot of contempt for your opponent to think they might helpmate with an underpromotion.
Answers.UserDisplayName: eyeballfrog
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T09:35:42.893Z
Answers.Text: @eyeballfrog it's a miniscule chance, but non-zero. Surely an engine would see almost zero as preferable to zero
Answers.UserDisplayName: Darren H
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T11:31:55.940Z
Answers.Text: Isn't the point about the possibility of a helpmate _not_ that there's any realistic chance that black will help white deliver mate but _rather_ that because mate is still possible in principle, if black runs out of time then the result will be a W win rather than a draw?
Answers.UserDisplayName: Gareth McCaughan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T13:25:17.613Z
Answers.Text: @DarrenH Engines like Stockfish don't “comprehend” of that as a possibility.
Answers.UserDisplayName: wizzwizz4
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T18:56:06.493Z
Answers.Text: @DarrenH - the engine will prefer to take the guaranteed half-point, rather than play a "hope chess" line and possibly walk away with nothing.  All this being said, there are certainly chess programs/engines that will deliberately play something other than the best available move (even to the extent of purposely making outright mistakes), just to kind of mix things up or simulate a less skilled player.  But an engine that is trying to work towards the best available result is going to just take the half-point and call it a day.
Answers.UserDisplayName: patbarron
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-29T09:11:41.210Z
Answers.Text: @patbarron: The problem obviously being, that computers have only an evaluation function, and it is a nontrivial job to include a fallible opponent into it. How many pawn units shall you "sacrifice" for a possible reward?
Answers.UserDisplayName: Hauke Reddmann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-29T17:58:26.423Z
Answers.Text: @DarrenH: More generally: Chess is a deterministic game. Engines don't "think" in terms of chances or probabilities, they think in terms of the evaluation function. In this particular example, the game is clearly drawn at the start, clearly continues to be drawn for most of the rest of the game, and the evaluation function should be approximately zero at all points except right after 14. ... Na2 (after which it should be the numerical equivalent of "mate in one"). Because Black has several other moves it could play which do not lose mate in one, the engine discounts this blunder entirely.
Answers.UserDisplayName: Kevin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-29T19:15:52.123Z
Answers.Text: @patbarron Let's put paid to the 'possibly walk away with nothing' stuff. There is an obvious way to avoid that (just keep an eye on the queening square) and no probability whatsoever of a white loss if the engine is careful (which the engine knows it will be), whereas there is a non-zero probability of a black loss (if black is *particularly* 'non-optimal', which the engine doesn't know he will *not* be!). Hence playing on till ...g8=Q is indeed better. That engine contempt which stretches this far doesn't currently exist is noteworthy. *Why* is an extremely interesting question (to me).
Answers.UserDisplayName: Mobeus Zoom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-30T07:12:12.337Z
Answers.Text: @DarrenH Which of these two minuscule chances is more minuscule: that the human player will walk into that helpmate, or that the computer will lose as a result of a hardware failure while waiting for the human to helpmate himself?
Answers.UserDisplayName: bof
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-27T21:27:25.687Z
Answers.LastActivityDate: 2021-06-27T21:27:25.687Z
Answers.UserDisplayName: patbarron
Answers.Body: <p>Engines are usually coded with the assumption that their opponent will play the best moves that they can imagine, as pointed out by Pat Barron above. This is called a minimax decision rule.</p>
  <p>Just to explain why this rule is used - it is a simplifying assumption. If you code or train the engine any other way, you will need two models - one for the opponent, and one for the engine. Using minimax, you only need one model - the engine effectively assumes it is playing itself and acts accordingly.</p>
  <p>The idea of exploiting opponents based on a reading of their ability is a very interesting one, but it would be a wholly different challenge to just learning to play chess as well as you can. The problem with an engine that assumes its opponent is weak, is that (for example) you can hustle it by pretending to be weak, and springing a trap. AI algorithms tend to be extremely fragile to exploitative attacks like this, and have limited ability to learn between games to prevent it happening over and over again.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-29T19:26:24.397Z
Answers.Text: very interesting but I've never heard of AI (neural networks at least) being used for contempt. Can you expand your idea - how exactly could the engine build up 'a model' of the opponent, playing any differently to the moves the engine considers optimal?
Answers.UserDisplayName: Mobeus Zoom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-29T20:37:57.167Z
Answers.Text: @Mobeus Zoom By AI I meant the old sense - any algorithm, not necessarily a sophisticated model. A very simple way would be to adjust contempt linearly depending on the estimated quality of the opponent's moves. This may or may not work.
  
  Another method would be to try to infer the opponent's next move, given their previous moves - so rather than train their model to win, train it to imitate opponents based on real play data. Here's [some research on this](https://towardsdatascience.com/generative-adversarial-imitation-learning-advantages-limits-7c87fc67e42d)
Answers.UserDisplayName: dilaudid
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-25T15:52:55.753Z
Answers.Text: A more interesting notion would be allowing an engine to be configured to maximize the value of practice an opponent might gain by playing against it.  If there is a situation where an opponent could force a draw with perfect play that was genuinely hard to find, but would otherwise lose, having a chess engine put its opponent in a position of having to find the difficult plays could be more useful than simply moving onto the next game, but if none of the required plays are difficult, going for the longer draw would simply waste the player's time.
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T19:08:17.567Z
Answers.LastActivityDate: 2021-06-28T19:08:17.567Z
Answers.UserDisplayName: dilaudid
Answers.Body: <p>The situation above is that if white makes any move other than Bxg7.</p>
  <p>Then black goes g1=Q and has the advantage with the possibility of a win if black can take the bishop.</p>
  <p>The table has a list of draws, they all assume that white plays a lot better than ignoring taking a pawn that is about to be promoted.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T16:03:29.830Z
Answers.Text: After g1=Q, the next move would be Bxg1, which is a draw. And it's easy to make sure the bishop doesn't get taken.
Answers.UserDisplayName: Joseph Sible-Reinstate Monica
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-28T15:34:55.457Z
Answers.LastActivityDate: 2021-06-28T15:34:55.457Z
Answers.UserDisplayName: Ronald Duncan
Body: <p>Consider a chess position like this one:</p>
  <pre><code>[FEN &quot;K7/4k1p1/8/8/3B4/8/8/8 w - - 0 1&quot;]
  
  1. Ka7 (1. Bxg7) 1... g5 2. Ka6 Kd6 3. Ka5 Kd5 4. Ba7 Kc4 5. Bb6 Kc3 6. Bc5 Kb2 7. Ka4 Ka1 8. Kb3 g4 9. Kc2 g3 10. Bb4 g2 11. Bc5 g1=N (11... g1=Q 12. Bxg1) 12. Bb4 Ne2 13. Bc5 Nc1 14. Ba3 Na2 15. Bb2#
  </code></pre>
  <p><a href="https://syzygy-tables.info/?fen=K7/4k1p1/8/8/3B4/8/8/8_w_-_-_0_1" rel="noreferrer">No forced mate is possible there</a>. But a helpmate is possible, so if Black runs out of time, or just plays exceptionally terribly, then White will win. Given that, why does Stockfish <a href="https://lichess.org/analysis/standard/K7/4k1p1/8/8/3B4/8/8/8_w_-_-_0_1" rel="noreferrer">pick Bxg7 there</a>, which immediately ends the game in a draw, rather than picking basically any other move (except for the losing Bf6+) to at least have some hope of winning?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-27T21:28:47.177Z
Comments.Text: You left out "or die from a heart attack" which is much better odds than the helpmate.
Comments.UserDisplayName: bof
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-27T22:11:04.190Z
Comments.Text: Engines are made to help us find "objective truth" about a posiiton. They're meant to be analysis tools, not competitive players
Comments.UserDisplayName: David
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-27T23:44:18.057Z
Comments.Text: How does White helpmate if Black plays ...g1=Q?
Comments.UserDisplayName: Allure
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-27T23:47:58.880Z
Comments.Text: @Allure If that happens, then I don't think helpmate is possible anymore, so White would just play Bxg1 and draw at that point. The hope is that Black would play ...g1=N instead (or realistically, run out of time before that happens).
Comments.UserDisplayName: Joseph Sible-Reinstate Monica
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-28T15:15:35.577Z
Comments.Text: If you're hoping b might run out of time or blunders and let you have a win instead of a draw, why aren't you worried that you might run out of time or blunder and take a loss instead of an easy draw?
Comments.UserDisplayName: Shufflepants
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-28T15:37:18.070Z
Comments.Text: You can also escape checkmate if your opponent doesn't realize you've been checkmated.  Would you expect an engine to consider such a line?
Comments.UserDisplayName: J...
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-28T16:08:04.393Z
Comments.Text: @J... No, because it can only happen if the rules of chess are broken. My question is about a win that's overwhelmingly unlikely (unless the opponent runs out of time), but theoretically possible without having to break any rules.
Comments.UserDisplayName: Joseph Sible-Reinstate Monica
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T10:55:07.443Z
Comments.Text: I'm going to give an unusual answer. Another answer said: > Engines don't play "hope chess" So I ask back: Why not? I think it would definitely be possible to construct an engine that plays *hope chess* successfully. It would be an engine constructed to play specifically against humans. I understand that engines are often built and calibrated by playing against themselves or against other engines. Doing that optimizes playing strength when fighting an engine. You could make an engine that fights humans specifically. Humans do this all the time. Many GM-level games are fought with some componen
Comments.UserDisplayName: usr
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T19:06:41.077Z
Comments.Text: Excellent question (belied by not mentioning contempt in the question itself) - but is helpmate really possible here? Is there a KB vs KN config which works, or indeed a KB vs KB where the black bishop is also dark-squared?
Comments.UserDisplayName: Mobeus Zoom
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T21:02:54.297Z
Comments.Text: @MobeusZoom KB vs KN works. My question contains a possible sequence.
Comments.UserDisplayName: Joseph Sible-Reinstate Monica
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T21:41:59.517Z
Comments.Text: @JosephSible-ReinstateMonica Indeed. Most of these answers sell themselves short of the point because your question doesn't indicate that 1) you know engines assume optimal followup as best they can, 2) you know contempt exists. The real answer to your question is twofold: firstly, contempt settings do not exist to this degree (i.e. to be able to expect a helpmate, or even random play); secondly, even if they did, and were turned on, Stockfish is just not built to solve helpmate puzzles (so it just will not see the path to the helpmating position you mention).
Comments.UserDisplayName: Mobeus Zoom
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T22:31:51.067Z
Comments.Text: @JosephSible-ReinstateMonica If you are interested in knowing *why*, it may behoove you to heavily edit or open a new question specifically on that
Comments.UserDisplayName: Mobeus Zoom
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-30T07:07:08.983Z
Comments.Text: An engine programmed to play that position the way you propose would probably lose or forfeit on account of a hardware failure more often than its human opponent would play into the helpmate.
Comments.UserDisplayName: bof
Tags: <engines><draw>
Title: Why do chess engines cause immediate draws rather than giving the opponent the opportunity to blunder or run out of time?
ThreadText: # Why do chess engines cause immediate draws rather than giving the opponent the opportunity to blunder or run out of time?
  
  (Asked by: username_0 on 2021-06-27)
  
  Consider a chess position like this one:
  
  ```
  [FEN "K7/4k1p1/8/8/3B4/8/8/8 w - - 0 1"]
  
  1. Ka7 (1. Bxg7) 1... g5 2. Ka6 Kd6 3. Ka5 Kd5 4. Ba7 Kc4 5. Bb6 Kc3 6. Bc5 Kb2 7. Ka4 Ka1 8. Kb3 g4 9. Kc2 g3 10. Bb4 g2 11. Bc5 g1=N (11... g1=Q 12. Bxg1) 12. Bb4 Ne2 13. Bc5 Nc1 14. Ba3 Na2 15. Bb2#
  
  ```
  
  [No forced mate is possible there](https://syzygy-tables.info/?fen=K7/4k1p1/8/8/3B4/8/8/8_w_-_-_0_1). But a helpmate is possible, so if Black runs out of time, or just plays exceptionally terribly, then White will win. Given that, why does Stockfish [pick Bxg7 there](https://lichess.org/analysis/standard/K7/4k1p1/8/8/3B4/8/8/8_w_-_-_0_1), which immediately ends the game in a draw, rather than picking basically any other move (except for the losing Bf6+) to at least have some hope of winning?
  
  **Tags:** engines, draw
  
  > **Comments:**
  > **username_1**: You left out "or die from a heart attack" which is much better odds than the helpmate.  
  > **username_2**: Engines are made to help us find "objective truth" about a posiiton. They're meant to be analysis tools, not competitive players  
  > **username_3**: How does White helpmate if Black plays ...g1=Q?  
  > **username_0**: @username_3 If that happens, then I don't think helpmate is possible anymore, so White would just play Bxg1 and draw at that point. The hope is that Black would play ...g1=N instead (or realistically, run out of time before that happens).  
  > **username_4**: If you're hoping b might run out of time or blunders and let you have a win instead of a draw, why aren't you worried that you might run out of time or blunder and take a loss instead of an easy draw?  
  > **username_5**: You can also escape checkmate if your opponent doesn't realize you've been checkmated.  Would you expect an engine to consider such a line?  
  > **username_0**: @J... No, because it can only happen if the rules of chess are broken. My question is about a win that's overwhelmingly unlikely (unless the opponent runs out of time), but theoretically possible without having to break any rules.  
  > **username_6**: I'm going to give an unusual answer. Another answer said: > Engines don't play "hope chess" So I ask back: Why not? I think it would definitely be possible to construct an engine that plays *hope chess* successfully. It would be an engine constructed to play specifically against humans. I understand that engines are often built and calibrated by playing against themselves or against other engines. Doing that optimizes playing strength when fighting an engine. You could make an engine that fights humans specifically. Humans do this all the time. Many GM-level games are fought with some componen  
  > **username_7**: Excellent question (belied by not mentioning contempt in the question itself) - but is helpmate really possible here? Is there a KB vs KN config which works, or indeed a KB vs KB where the black bishop is also dark-squared?  
  > **username_0**: @username_7 KB vs KN works. My question contains a possible sequence.  
  > **username_7**: @username_0 Indeed. Most of these answers sell themselves short of the point because your question doesn't indicate that 1) you know engines assume optimal followup as best they can, 2) you know contempt exists. The real answer to your question is twofold: firstly, contempt settings do not exist to this degree (i.e. to be able to expect a helpmate, or even random play); secondly, even if they did, and were turned on, Stockfish is just not built to solve helpmate puzzles (so it just will not see the path to the helpmating position you mention).  
  > **username_7**: @username_0 If you are interested in knowing *why*, it may behoove you to heavily edit or open a new question specifically on that  
  > **username_1**: An engine programmed to play that position the way you propose would probably lose or forfeit on account of a hardware failure more often than its human opponent would play into the helpmate.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_8 on 2021-06-27. Score: 14
  
  Unlike playing with people, an engine will make the best move it can find, assuming perfect play on the part of the opponent. Engines don't play "hope chess" - they don't assume (or hope) that the opponent will make a mistake.
  
  > **Comments:**
  > **username_0**: Isn't the concept of contempt in chess engines exactly that they don't assume their opponent is perfect?  
  > **username_9**: @username_0 You'd need a lot of contempt for your opponent to think they might helpmate with an underpromotion.  
  > **username_10**: @username_9 it's a miniscule chance, but non-zero. Surely an engine would see almost zero as preferable to zero  
  > **username_11**: Isn't the point about the possibility of a helpmate _not_ that there's any realistic chance that black will help white deliver mate but _rather_ that because mate is still possible in principle, if black runs out of time then the result will be a W win rather than a draw?  
  > **username_12**: @username_10 Engines like Stockfish don't “comprehend” of that as a possibility.  
  > **username_8**: @username_10 - the engine will prefer to take the guaranteed half-point, rather than play a "hope chess" line and possibly walk away with nothing.  All this being said, there are certainly chess programs/engines that will deliberately play something other than the best available move (even to the extent of purposely making outright mistakes), just to kind of mix things up or simulate a less skilled player.  But an engine that is trying to work towards the best available result is going to just take the half-point and call it a day.  
  > **username_13**: @username_8: The problem obviously being, that computers have only an evaluation function, and it is a nontrivial job to include a fallible opponent into it. How many pawn units shall you "sacrifice" for a possible reward?  
  > **username_14**: @username_10: More generally: Chess is a deterministic game. Engines don't "think" in terms of chances or probabilities, they think in terms of the evaluation function. In this particular example, the game is clearly drawn at the start, clearly continues to be drawn for most of the rest of the game, and the evaluation function should be approximately zero at all points except right after 14. ... Na2 (after which it should be the numerical equivalent of "mate in one"). Because Black has several other moves it could play which do not lose mate in one, the engine discounts this blunder entirely.  
  > **username_7**: @username_8 Let's put paid to the 'possibly walk away with nothing' stuff. There is an obvious way to avoid that (just keep an eye on the queening square) and no probability whatsoever of a white loss if the engine is careful (which the engine knows it will be), whereas there is a non-zero probability of a black loss (if black is *particularly* 'non-optimal', which the engine doesn't know he will *not* be!). Hence playing on till ...g8=Q is indeed better. That engine contempt which stretches this far doesn't currently exist is noteworthy. *Why* is an extremely interesting question (to me).  
  > **username_1**: @username_10 Which of these two minuscule chances is more minuscule: that the human player will walk into that helpmate, or that the computer will lose as a result of a hardware failure while waiting for the human to helpmate himself?  
  
  ---
  
  ### Answer by username_15 on 2021-06-28. Score: 9
  
  Engines are usually coded with the assumption that their opponent will play the best moves that they can imagine, as pointed out by Pat Barron above. This is called a minimax decision rule.
  
  Just to explain why this rule is used - it is a simplifying assumption. If you code or train the engine any other way, you will need two models - one for the opponent, and one for the engine. Using minimax, you only need one model - the engine effectively assumes it is playing itself and acts accordingly.
  
  The idea of exploiting opponents based on a reading of their ability is a very interesting one, but it would be a wholly different challenge to just learning to play chess as well as you can. The problem with an engine that assumes its opponent is weak, is that (for example) you can hustle it by pretending to be weak, and springing a trap. AI algorithms tend to be extremely fragile to exploitative attacks like this, and have limited ability to learn between games to prevent it happening over and over again.
  
  > **Comments:**
  > **username_7**: very interesting but I've never heard of AI (neural networks at least) being used for contempt. Can you expand your idea - how exactly could the engine build up 'a model' of the opponent, playing any differently to the moves the engine considers optimal?  
  > **username_15**: @username_7 By AI I meant the old sense - any algorithm, not necessarily a sophisticated model. A very simple way would be to adjust contempt linearly depending on the estimated quality of the opponent's moves. This may or may not work.  Another method would be to try to infer the opponent's next move, given their previous moves - so rather than train their model to win, train it to imitate opponents based on real play data. Here's [some research on this](https://towardsdatascience.com/generative-adversarial-imitation-learning-advantages-limits-7c87fc67e42d)  
  > **username_16**: A more interesting notion would be allowing an engine to be configured to maximize the value of practice an opponent might gain by playing against it.  If there is a situation where an opponent could force a draw with perfect play that was genuinely hard to find, but would otherwise lose, having a chess engine put its opponent in a position of having to find the difficult plays could be more useful than simply moving onto the next game, but if none of the required plays are difficult, going for the longer draw would simply waste the player's time.  
  
  ---
  
  ### Answer by username_17 on 2021-06-28. Score: 1
  
  The situation above is that if white makes any move other than Bxg7.
  
  Then black goes g1=Q and has the advantage with the possibility of a win if black can take the bishop.
  
  The table has a list of draws, they all assume that white plays a lot better than ignoring taking a pawn that is about to be promoted.
  
  > **Comments:**
  > **username_0**: After g1=Q, the next move would be Bxg1, which is a draw. And it's easy to make sure the bishop doesn't get taken.  
  
  ---
  
  