When and how to use Leela Chess Zero and when Stockfish

When and how to use Leela Chess Zero and when Stockfish

NM HanSchut

The TCEC Computer Chess Superfinal Season 15 was won for the first time by Leela Chess Zero. Lc0 defeated Stockfish in the final convincingly with 53.5 - 46.5 with 14 wins for Lc0 and 7 for Stockfish. Stockfish had won seasons 11 to 14 dominating over Houdini and Komodo.

LcO has been inspired by DeepMind's AlphaZero. Stockfish uses traditional alpha-beta tree search in combination with an evaluation function designed by expert human players and programmers. LcO, on the other hand. learns entirely on it's own, capturing it's knowledge in a neural network and uses a variant of Monte Carlo Tree Search to  find the most promising continuation.

In this blog I will look into the relative strength and weaknesses of these 2 top engines. Please realize that both engines are rated around 3500 so these differences might be irrelevant for most users.

Magnus Carlsen stated that AlphaZero is leading humans to reevaluate the trade off between long term activity and initiative versus material sacrifices. This is less 'one dimensional' than people often think, as GM Peter Heine Nielsen, the second of WC Magnus Carlsen points out in New In Chess Magazine 2019/#5 in his analysis of the classical game between Magnus Carlsen and Shakhriyar Mamedyarov:

Position after 15.h6!

'I recently attributed the modern appreciation of flank attacks to AlphaZero, and some people pointed out to me that opening the h-file and giving mate is not exactly a new concept in chess! A fair point, so this diagram is a good opportunity to point out what AlphaZero has a preference for, according to Sadler and Regan in their book Game Changer. Precisely ! Not going for a direct assault on the h-file but instead slowly and more cunningly putting the pawn on h6, effectively closing the h-file and instead aiming for a slower and more long term attack. The benefits are numerous: it controls space in the critical area next to Black's king, cramping his defence, and, as in this game, forcing the bishop to h8, where it blocks the kings's potential retreat. Moreover, in tactical sequences the pawn is only two squares away from queening. Not at all as direct as the typical hxg6 and mate along the h-file, but sometimes much more powerful."

The TCEC Superfinal is played with staged openings selected by Jeroen Noomen. LcO won both it's White and Black game in the Trompowsky (game 61 and 62). 

Position after 20... hxg5
Stockfish evaluated this position as better for White (0.7) while Leela Chess Zero had a strong preference for Black's position (-1.2). GM Matthew Sadler writes the following about this position in the very interesting article The TCEC15 Computer Chess Superfinal: a perspective:
"White’s essential problem is that with the kingside blocked, the major action will take place on the queen side. However, White’s king side structure - particularly the pawn on g4 - is so fragile that White will always need pieces there to defend it, and this reduces the forces that White can commit to either attacking or defending on the queenside. In other words, we have a “total board” situation in which the situation on the kingside affects the situation on the queenside in the middle to long-term. "
Again, not a one-dimensional explanation, like 'Black can attack on the queenside (not blocked) and White can not attack on the kingside (blocked) and that is why Black is better. The added nuance is that White has to commit resources to the defence of his fragile kingside structure leaving him with insufficient resources to defend on the queenside.

A striking difference between the two engines is the number of positions that are being considered when generating moves. Stockfish searches wider and deeper, Leela Chess Zero uses the knowledge contained in it's network to limit the breadth and depth of it's search. Stockfish won the following game based on deeper calculation.

Position after 25... Rae8.
After 26.h6! Stockfish evaluated the position as completely winning (+7.9) while LcO thought it was only slightly worse (+0.65). So a relative strength of Stockfish is it tactical vision based on deep calculation.
The relative strength of the 2 engines is rooted in their architecture. In positions that are less concrete and more strategic, LcO might evaluate the position better and find new pathways that are not being considered by traditional engines. In tactical play, Stockfish might find  a winning combination that is not on LcO's horizon yet. 
The following unique strategies of AlphaZero are from the book Game Changer by Mathew Sadler and Natasha Regan and highlight further relative strengths of AZ/LcO
- Restrict mobility opponents pieces while improving its own pieces;
- Trade active pieces of the opponent leaving him with passive pieces
- Use of the rook's pawn for a long term attack on the opponent;s king
- Create weak color complexes around the opponent's king
- Sacrifice material for time, space and gaining access to the king
- Castle opposite to have more opportunity to attack the opponent's king
- Defending by sacrificing material for initiative

Leela Chess Zero runs best on GPUs or TPUs. If you are considering buying a new computer this fall and want to run LcO local then have a look at a computer with a powerful GPU like the NVDIA Geforce RTX 2080 Ti. 

You can use LcO for your analysis of your games in 3 ways:

1. On your local computer using your own GPU

See the LcO blog Running Leela Chess Zero in a Chess GUI for instructions. 

To run LcO on a local GPU you have to let your local GPU know that it also should run programs and not just do the Graphics Processing. On my Microsoft Surface book that meant first installing the Nvdia CUDA Toolkit before doing the steps in the link above. I would not recommend running LcO on your CPU because of the drop in performance.

The LcO developers have just started to complete retrain Leela Chess Zero. The latest program is v022 and one of the best neural network weights 42850. Do not use more recent neural network weights.

2. Rent a LcO cloud engine on Chessbase

3. Set up a Google Cloud account and run LcO engine in that environment

A trial account is free and the computing is very fast.

If there are users who analyse with Leela Chess Zero in a different set-up, then I am interested to learn from them.