Random Posts

Monday, March 11, 2019

Stockfish 10 Contempt Settings

     I am not an engine guru, but after using Stockfish 10 for a while I have noticed some strange behavior in its evaluation function that has to do with its contempt setting. 
    The contempt setting controls how readily the engine will play for a draw. The higher the value the stronger the effect on the engine and the more it will try to avoid a draw even if it means playing something other than the optimal move. If the engine has high contempt setting it might exhibit a more attacking style. 
     The default contempt setting for Stockfish 8 was zero, Stockfish 9 was 20 and for Stockfish 10 it is 24. Programmers did this because in some computer tournaments Stockfish was playing too many draws and by raising the contempt setting, the engine was able to score more points against weaker engines without losing too much objective strength against the stronger engines. This idea may sometimes be seen in games between human players when a player tries to keep the tension in a position which creates more scope for his weaker opponent to make a mistake. 
     But, what if you are playing in engine assisted tournaments against other Stockfish users? Might not the higher settings result in losing more games by trying to avoid the draw because the engine is not recommending the absolute best move? 
     If you are looking for the absolute best move in a given position, it might not be the engine's first choice. According to Russell Sherwood of the Welsh Chess Federation, "General opinion for CC has been that contempt settings should be set to zero to get a more accurate assessment of the position, however, there are different views on this." Mr. Sherwood has written some interesting articles on correspondence chess and the use of engines on the Welsh website
     I am not exactly sure how the contempt setting works. On one site I read that when the engine starts analyzing from a position it gives a “bonus” in the form of the contempt setting to whichever side is on the move. The result that the evaluation keeps bouncing back and forth and, according to the poster, the transposition table is filled with conflicting evaluation scores. 
     Another person wrote that was incorrect. According to him, the engine searches and returns its best move and the expected reply (known as the ponder move) so the engine is always searching from the same side to move.
     Whatever is going on, when analyzing with Stockfish 10 I have noticed what one person called “a strange yo-yo-effect especially at the beginning of the game” (also referred to as the “roller coaster effect”) that results in wild fluctuations in the evaluation every time a move is actually made on the board. His explanation was, like previously mentioned, it is because the contempt factor is switched back and forth to whichever side has the move. 
     I don’t know who is correct, but take the following position. 


I used two cores with the hash table at 1168 and gave Stockfish 10 five minutes to evaluate the position. 
Contempt setting: 24 Evaluation: -1.71 
Contempt setting: 20 Evaluation: -1.42 
Contempt setting: 0 Evaluation: -1.27 

     Clearly the contempt setting changes the evaluation, the difference in this case by as much as almost a half a Pawn. For anybody that’s interested, there is an interesting discussion at Talkchess,com.

5 comments:

  1. excellent article. mention that stockfish has always "analysis contempt" on. other engine do not. others do not use contempt for infinitely analysis purposes. i might be an good idea to turn stockfish's analysis contempt off when playing corr chess ?!

    ReplyDelete
  2. I am no expert but seems to me that setting the contempt to "OFF" means that the engine is not going to artificially goof around with the moves. I guess I will have to see how it works out in games where a draw is possible. Stockfish comes with 3 different engine styles, not sure what the differences are but the 10x64 version seems to win the most among the three, so that is the one I use. I also play with "ponder on". I have no worries about strong or weak engines trying to outguess them, it is what it is.

    ReplyDelete
  3. How does CPU threading effect Contempt?
    Case in point:
    Threadripper 16 core 32 threads.More effective with 16 threads,or the full 32?

    ReplyDelete
  4. i need all setting for stockfish 10.
    i am stranger about stockfish engine.you can email all setting. i play tournanent of 4 minutes. which setting is best. reply me.

    ReplyDelete
  5. Stockfish 10 is already optimized for blitz as explained in paragraph 3 so there is no need to change anything.

    ReplyDelete