Monday, June 25, 2018

Contempt

Earlier this year I wrote about how wrong it would be to shed Stockfish after his defeat against Alpha Zero (see to analyze using a computer part 3). In the last TCEC season 11 it became clear for everybody that this engine will still play a very important role at chess in the nearby future. First Stockfish qualified for the superfinal 7 points ahead of the number 2 Houdini. Then we saw a remarkable for this era of super-advanced engines a very one-sided battle. The convincing victory of Stockfish with 20 victories against 2 losses (for the rest only draws) was something we hadn't met anymore in the last decade.

The supremacy of Stockfish was probably the best shown in the double victory during the super-final when the Mar del Plata variation of the Kings Indian had to be played. First Stockfish won with the white pieces.
[Event "TCEC Season 11 - Superfinal"] [Site "http://tcec.chessdom.com"] [Date "2018.04.03"] [Round "29"] [White "Stockfish 260318"] [Black "Houdini 6.03"] [Result "1-0"] [ECO "E99"] [WhiteElo "3546"] [BlackElo "3489"] [PlyCount "140"] [EventDate "2018.03.29"] 1.d4 Nf6 2.c4 g6 3.Nc3 Bg7 4.e4 d6 5.Nf3 O-O 6.Be2 e5 7.O-O Nc6 8.d5 Ne7 9.Ne1 Nd7 10.Be3 f5 11.f3 f4 12.Bf2 g5 13.Nd3 Nf6 14.c5 Ng6 15.Rc1 Rf7 16.c6 bxc6 17.dxc6 Be6 18.Nb4 a5 19.Nbd5 Nxd5 20.Nxd5 Ne7 21.a3 Nxd5 22.exd5 Bc8 23.Rc4 h5 24.b4 axb4 25.axb4 g4 26.fxg4 Ba6 27.Rc1 Bc8 28.Rc4 Ba6 29.Re4 Bxe2 30.Qxe2 Qg5 31.b5 hxg4 32.b6 cxb6 33.Bxb6 Qg6 34.Rc4 Rb8 35.c7 Rc8 36.Rfc1 Bh6 37.Qc2 Qxc2 38.R1xc2 Kf8 39.R2c3 Bg5 40.h3 gxh3 41.Rxh3 Ke7 42.Ba5 Kd7 43.Rb4 f3 44.Rb8 Be3+ 45.Kf1 fxg2+ 46.Kxg2 Rxc7 47.Bxc7 Kxc7 48.Rb1 Ba7 49.Rh8 Bb6 50.Re8 Kb7 51.Re6 Kc7 52.Re8 Kb7 53.Re6 Kc7 54.Kh3 Bc5 55.Rb3 Rd7 56.Kg4 Kc8 57.Kf5 Rf7+ 58.Kg6 Rb7 59.Rh3 Kc7 60.Re7+ Kb8 61.Re8+ Ka7 62.Rh2 Rb4 63.Kf5 Kb7 64.Rg8 Kb6 65.Ra8 Rd4 66.Rb8+ Kc7 67.Rhh8 Rh4 68.Rhc8+ Kd7 69.Rg8 Kc7 70.Rb5 Rb4 1-0
Next as for all chosen openings in the super-final, the colors were reversed for the engines (so no engine is privileged by the opening-choice). Again Stockfish won so this time with the black pieces.
[Event "TCEC Season 11 - Superfinal"] [Site "http://tcec.chessdom.com"] [Date "2018.04.03"] [Round "30"] [White "Houdini 6.03"] [Black "Stockfish 260318"] [Result "0-1"] [ECO "E99"] [WhiteElo "3489"] [BlackElo "3546"] [PlyCount "119"] [EventDate "2018.03.29"] 1.d4 Nf6 2.c4 g6 3.Nc3 Bg7 4.e4 d6 5.Nf3 O-O 6.Be2 e5 7.O-O Nc6 8.d5 Ne7 9.Ne1 Nd7 10.Be3 f5 11.f3 f4 12.Bf2 g5 13.Nd3 Nf6 14.c5 Ng6 15.Kh1 Rf7 16.a4 h5 17.a5 g4 18.a6 g3 19.hxg3 fxg3 20.Bxg3 h4 21.axb7 Bxb7 22.Be1 Nh5 23.Rg1 Bf6 24.Bd2 Rg7 25.Kh2 Bg5 26.b4 Bc8 27.Bf1 Qf6 28.Ne2 Bxd2 29.Qxd2 Nf8 30.b5 Ng3 31.Qc1 Qg6 32.Nc3 a5 33.Nf2 Nd7 34.c6 Nf6 35.Nd3 Nfh5 36.Qe1 Qh6 37.Qc1 Qf6 38.Ra3 Kf7 39.f4 Nxf4 40.Nxf4 exf4 41.Ne2 Bg4 42.Nxf4 Qe5 43.Bc4 Kg8 44.b6 cxb6 45.Ra2 Rf8 46.Rf2 Nxe4 47.Re1 Rgf7 48.Qb2 Qxb2 49.Rxb2 Rxf4 50.Be2 Bxe2 51.Rbxe2 Nf6 52.Re6 Rc4 53.Rxd6 b5 54.c7 Rxc7 55.Ra6 a4 56.d6 Rg7 57.Rg1 Ng4+ 58.Kh1 Rf5 59.Ra8+ Kh7 60.Rc8 0-1
After the match there was naturally a lot of talk about how Stockfish could make so much progress in such short notice. Hereby people quickly pointed to a new parameter of Stockfish: the contempt-factor. That needs a bit more explanation. First this parameter isn't new at all. Such contempt-factor exists for a long time but only recently the developers of Stockfish decided to use it intensively. The advantage is neither always obvious. In the previous TCEC season Stockfish made a bit too many draws against weaker engines which caused it to miss the final. As anti-dote the engine was adapted by playing moves leading to less exchanges of pieces so keeping the tension longer in a position which creates more scope for errors. Concretely this means Stockfish doesn't always play the best moves of its algorithms within an acceptable margin (defined by the contempt) to create more winning-chances. Besides this strategy is well-known in practical chess between humans see my article playing the man. However engine-play is very different.

The gain against weaker engines may not generate more losses against the strong engines. Nowadays a lot of experiments are done with a dynamic contempt instead of a pure static contempt see tests of Stockfish. They adapt the size of the contempt to the evaluation of the position. You could allow exchanges more quickly in an inferior position or the opposite.

So engines continue to develop. Also don't expect that Stockfish will rule the world alone in the future. Last month there was big news for its main-rival Komodo. The engine was acquired by chess.com see this announcement which will definitely boost the engine. The prediction already starts to materialize in the currently ongoing TCEC season 12 in which Komodo qualified as first engine and started the super-final with a win against the latest release of Stockfish.

For sure fans of engine-chess have something to look forward. Still this is and remains a niche which we see translated in the number of visitors. Stockfish is many hundreds of points stronger than the reigning world-champion Magnus Calsen. Nevertheless Magnus' games are 1000 more often viewed. For the regular chess-player an engine is only used to get an evaluation of a position or to make some analysis. As a consequence most just take the strongest available engine to do this job. Naturally it is a bonus that today this strongest engine so Stockfish comes without any charges.

However very few know that you need to be careful when using the latest version of the engine for the analysis. The evaluations are less accurate than previous releases of the same engine or of other top-engines if not interpreted correctly. That is because of the contempt-factor which influences the evaluations. When white's move avoids exchanges then a bonus of 0,2 is giving to white. For black such type of move would generate a negative bonus of -0,2. Such manipulations of the evaluation cause some strange yo-yo-effect especially at the beginning of the game. Even when no mistakes are made then we notice fluctuations of almost a half pawn. By applying the evaluation-profile of the Fritz-interface on a game with no serious errors, this becomes very visible.
Stockfish 9 with contempt (10 seconds per move)









These swings disappear in the first 20 moves when we make an evaluation-profile with the Fritz interface after resettting the contempt of Stockfish to 0. Below screenshot makes this again very clear.
Stockfish 9 without contempt (10 seconds per move)







This is our normal evaluation-pattern we need as base to comment games see annotations or to make some deep opening-analysis see to study openings part 2. For the analysis we want mainly an objective evaluation of how strong the moves are and not which moves create the best winning chances for Stockfish against other engines.

To eliminate the contempt can be done in the Fritz interface by looking up the settings of Stockfish. You only need to change the contempt-value from 20 to 0 see screenshot below.
Stockfish parameters
The only issue of this solution is that the Fritz-interface doesn't allow you to save this setting as default. So each time you start up Stockfish, you have to redo this. That is fine if you only use the engine sporadically but for intensive usage this is very annoying. On the internet I searched for a better alternative which I eventually found see stockfish 9 for analysis. There you can download a special compiled version of Stockfish more appropriate for analysis. In that version you don't need to reset each time anymore the contempt-parameter to 0.

It is not the only limitation of the default-settings in the Fritz-interface. I also don't manage to get the interface remember that it should not add my name as annotator. Each time I save any analysis, I have to remove manually my name. It is only 2 seconds work but in a couple of months this happens sometimes 1000 times so I am still wasting quite some time.
Another flaw in the default-setting is in the new application automatic analysis of the games played online at playchess. Recently I am playing again more blitz online (due to a lack of serious competitions). However when I want to check the openings of the blitz-games with an engine using the Fritz-interface see my article the (non-)sense of blitz then I am always disturbed by pop-up windows about tactical blunders spotted by the engine-trainer. It is today impossible to switch off this trainer forever.





There exist today other interfaces than Chessbase for engines but none can compete as they all have much less functionality. So Chessbase has an absolute monopoly which isn't good for the end-user. Today we see that the developments mainly happen around more functionality for the large community so they are persuaded of buying newer releases of their products. It is not financially interesting to optimize existing functionality for the few intensive users (they only make a couple percentages of the total customer-base). Besides few or no Chessbase-programmers are today active strong tournament-players see e.g. the interview with Matthias Wuellenweber in 2018. Playing professional chess and programming is a very difficult combination.

Brabo