Answers.Body: <p>No source, but I eventually found out (from other computer chess viewers) that Stockfish NNUE does not have contempt <em>per se</em> - it's not clear how to implement contempt in NNs. However, Stockfish NNUE does use the handcrafted eval in certain positions, so there is still a contempt setting. Apparently, however, the effect is minuscule. Before NNUE, contempt=100 Stockfish plays a vastly different game from c=0 Stockfish; now they're similar (which shouldn't be surprising since handcrafted eval is not used often).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-02T06:11:47.523Z
Answers.LastActivityDate: 2020-10-02T06:11:47.523Z
Answers.UserDisplayName: Allure
Answers.Body: <p>I'm not sure if you understanding of contempt is right, but in any case; I just compiled SF12 and it seems you don't have two versions of SF (the standard and the NNUE) but you can set your SF12 to behave standard or NNUE. In the <a href="https://i.sstatic.net/8Zu7n.jpg" rel="nofollow noreferrer">configuration screen for SF12</a> you can enable NNUE, and also the contempt value.</p>
  <p>So the short answer to your question is yes, SF12-NNUE has contempt implemented.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T15:01:07.740Z
Answers.LastActivityDate: 2020-09-04T15:01:07.740Z
Answers.UserDisplayName: emdio
Answers.Body: <p>Contempt is implemented. But your understanding is not correct. Evaluation is already counting all possible factors which engine considers. But it does not understand the idea of risk. So &quot;Contempt&quot; switch is like &quot;should I insist on evading of 3-rep/50-move rules when my eval says to repeat the move?&quot; and it is typically on/off. With contempt=on, engine will not repeat position 3 times, effectively dropping the line of repeating right away. Most of engines already have contempt=on. This switch comes with little &quot;margin&quot; function which basically says &quot;Am I losing that much to call for a draw?&quot;. If it does not see any losing, effectively it will not draw by itself. That function is very rarely used actually. Typically engines will always try to beat the opponent even if it will make them lose more. Most of the time engines don't have &quot;draw offering&quot; implemented.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T21:58:32.980Z
Answers.Text: This answer looks incorrect. I'm not familiar with Stockfish code, but from emdio's answer, contempt is a number. It ranges from -100 to +100, i.e. it is not "on" or "off".
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T23:34:07.207Z
Answers.Text: When engine is at disadvantage, opponent engine won't let it to draw by 3-rep. So number is practically not used. It is just theoretical value to tweak the feature itself.
Answers.UserDisplayName: sanaris
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T23:40:23.873Z
Answers.Text: I know Stockfish plays very differently when c = 100 as opposed to the default c = 24, so I can't believe that's the case.
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-02T14:06:05.110Z
Answers.Text: I think contempt is simply always added to the evaluation score. If contempt is 100 (or one pawn), then a position of -0.5 "looks like" 0.5, and therefore threefold repetition is avoided because it is worse than 0.5. If the choice is between repeating or a -1.5 position, then it still repeats.
Answers.UserDisplayName: RemcoGerlich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-04T19:33:42.867Z
Answers.LastActivityDate: 2020-09-04T19:33:42.867Z
Answers.UserDisplayName: sanaris
Body: <p>Per title. As I understand contempt, it's a setting in the eval function that adds a bonus for material remaining on the board. This makes the engine favor positions with more material (i.e. more complex, i.e. more scope to outplay the opponent). It is meant to make the engine avoid quick draws against inferior opposition.</p>
  <p>Stockfish recently implemented <a href="https://chess.stackexchange.com/questions/31754/what-does-stockfish-nnue-mean-for-stockfish">NNUE eval</a>, and I am unsure if NNUE eval can include contempt. If yes, how does it work? The description above doesn't seem to work anymore.</p>
  
Tags: <engines><stockfish>
Title: Does Stockfish NNUE have contempt implemented?
ThreadText: # Does Stockfish NNUE have contempt implemented?
  
  (Asked by: username_0 on 2020-09-04)
  
  Per title. As I understand contempt, it's a setting in the eval function that adds a bonus for material remaining on the board. This makes the engine favor positions with more material (i.e. more complex, i.e. more scope to outplay the opponent). It is meant to make the engine avoid quick draws against inferior opposition.
  
  Stockfish recently implemented [NNUE eval](https://chess.stackexchange.com/questions/31754/what-does-stockfish-nnue-mean-for-stockfish), and I am unsure if NNUE eval can include contempt. If yes, how does it work? The description above doesn't seem to work anymore.
  
  **Tags:** engines, stockfish
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2020-10-02. Score: 2 | Accepted answer
  
  No source, but I eventually found out (from other computer chess viewers) that Stockfish NNUE does not have contempt *per se* - it's not clear how to implement contempt in NNs. However, Stockfish NNUE does use the handcrafted eval in certain positions, so there is still a contempt setting. Apparently, however, the effect is minuscule. Before NNUE, contempt=100 Stockfish plays a vastly different game from c=0 Stockfish; now they're similar (which shouldn't be surprising since handcrafted eval is not used often).
  
  
  ---
  
  ### Answer by username_1 on 2020-09-04. Score: 4
  
  I'm not sure if you understanding of contempt is right, but in any case; I just compiled SF12 and it seems you don't have two versions of SF (the standard and the NNUE) but you can set your SF12 to behave standard or NNUE. In the [configuration screen for SF12](https://i.sstatic.net/8Zu7n.jpg) you can enable NNUE, and also the contempt value.
  
  So the short answer to your question is yes, SF12-NNUE has contempt implemented.
  
  
  ---
  
  ### Answer by username_2 on 2020-09-04. Score: 1
  
  Contempt is implemented. But your understanding is not correct. Evaluation is already counting all possible factors which engine considers. But it does not understand the idea of risk. So "Contempt" switch is like "should I insist on evading of 3-rep/50-move rules when my eval says to repeat the move?" and it is typically on/off. With contempt=on, engine will not repeat position 3 times, effectively dropping the line of repeating right away. Most of engines already have contempt=on. This switch comes with little "margin" function which basically says "Am I losing that much to call for a draw?". If it does not see any losing, effectively it will not draw by itself. That function is very rarely used actually. Typically engines will always try to beat the opponent even if it will make them lose more. Most of the time engines don't have "draw offering" implemented.
  
  > **Comments:**
  > **username_0**: This answer looks incorrect. I'm not familiar with Stockfish code, but from username_1's answer, contempt is a number. It ranges from -100 to +100, i.e. it is not "on" or "off".  
  > **username_2**: When engine is at disadvantage, opponent engine won't let it to draw by 3-rep. So number is practically not used. It is just theoretical value to tweak the feature itself.  
  > **username_0**: I know Stockfish plays very differently when c = 100 as opposed to the default c = 24, so I can't believe that's the case.  
  > **username_3**: I think contempt is simply always added to the evaluation score. If contempt is 100 (or one pawn), then a position of -0.5 "looks like" 0.5, and therefore threefold repetition is avoided because it is worse than 0.5. If the choice is between repeating or a -1.5 position, then it still repeats.  
  
  ---
  
  