Tag Archives: Leela Chess

Useful Technology?

This review has been printed in the March 2020 issue of Chess Life.  A penultimate (and unedited) version of the review is reproduced here. Minor differences exist between this and the printed version. My thanks to the good folks at Chess Life for allowing me to do so.


Kaufman, Larry. Kaufman’s New Repertoire for Black and White: A Complete, Sound and User-friendly Chess Opening Repertoire. Alkmaar: New in Chess, 2019. ISBN 9789056918620. PB 464pp.

Kaufman’s New Repertoire for Black and White: A Complete, Sound and User-Friendly Chess Opening Repertoire is the third incarnation of Larry Kaufman’s one-volume opening repertoire. While the first two – The Chess Advantage in Black and White: Opening Moves of the Grandmasters (2004) and The Kaufman Repertoire for Black and White: A Complete, Sound and User-Friendly Chess Opening Repertoire (2012) – were well-regarded, this new edition appears at something of an inflection point in the history of chess theory.

Opening theory has exploded over the past two decades, due largely to the influence of engines and databases. As one of the developers of Rybka and Komodo, among other important projects, Kaufman has made good use of engines in his writing, and both previous versions of this project proclaim the central role played by the computer. In 2004 it was Fritz, Junior, and Hiarcs, and in 2012 he used Houdini and especially Komodo.

Today the landscape has changed. The rise of artificial intelligence and neural network engines, first Alpha Zero and now Leela Chess Zero, is reshaping opening theory. In Mind Master, reviewed here last month, Viswanathan Anand relates that Caruana and Carlsen were the first elite players to make use of Leela in their 2018 match preparations, and that his trainer introduced it into their workflow at the end of that year.  Chess authors have picked up on the trend, and works written under Leela’s influence are beginning to appear.

Kaufman’s New Repertoire is advertised as “the first opening book that is primarily based on Monte Carlo search.” This is somewhat imprecise – Leela’s evaluations come from the neural network, not game rollouts – but the point remains that Kaufman has chosen to make use of the newest technologies in writing his book. He relied on Leela and a special “Monte Carlo” version of Komodo to craft the repertoire, generally deferring to Leela’s view while reserving the right to serve as “referee” if the engines disagree.

So what does Kaufman’s new repertoire look like? As the title suggests, the book contains a complete opening solution for both colors, focusing on 1. e4 for White, and the Grunfeld and Ruy Lopez for Black. Kaufman is covering a lot of ground here, generally offering two systems or ideas against most major continuations. In the mainline Ruy he offers readers three choices with Black: the Breyer, the Marshall, and the Møller.

The virtue of this approach is clear. Kaufman’s New Repertoire gives readers a one-stop opening repertoire, featuring professional lines, particularly with Black, and computer-tested ideas that can inspire confidence. But in an age where multi-volume single color repertoires are increasingly the norm, is it possible to include enough detail in less than 500 pages?

Let’s dive a bit deeper and take a look at specific recommendations.

White: 1. e4
  • vs Caro-Kann – (a) 4. Bd3 Exchange Variation, (b) 3. Nc3 dxe4 4. Nxe4 Bf5 5. Qf3!?, (c) Two Knights.
  • vs French – Tarrasch Variation.
  • vs 1. … e5 – (a) Italian Game, with multiple repertoire choices offered, (b) Ruy Lopez with 6. d3, and 5. Re1 against Berlin.
  • vs Sicilian – (a) 2. Nc3 ideas, including 2. Nc3 d6 3. d4 cxd4 4. Qxd4 Nc6 5. Qd2 and the anti-Sveshnikov 2. Nc3 Nc6 3. Nf3 e5 4. Bc4; (b) 2. Nf3 and 3. Bb5 against 2. … d6 and 2. … Nc6, and 3. c3 against 2. … e6, entering the Alapin.
Black: 1. e4 e5 and Grunfeld
  • … Nf6 against the Scotch.
  • … Bd6 against the Scotch Four Knights.
  • … Bc5 in the Italian game, focusing on 4. d3 Nf6 5. 0-0 0-0 and now 6. c3 d5, 6. Re1 Ng4, 6. a4 h6 followed by … a5, and 6. Nbd2 d6.
  • the Breyer is the “best all-purpose defense” in the 9. h3 Ruy Lopez, but Kaufman also includes Leela’s favored Marshall Attack and the Møller, inspired by Anand.
  • Neo-Grunfeld without … c6 vs the Fianchetto.
  • f3 Nc6.
  • …a6 against the Russian System.
  • … Qxa2 and 12. … b6 against 7. Nf3 in the Exchange variation.
  • three options – 10. … Qc7 11. Rc1 b6, 10. … e6, and 10. … b6 – against the 7. Bc4 Exchange.
  • c4 / 1. Nf3 – Anti-Grunfeld, Symmetrical English, and a tricky path into the Queen’s Indian Defense for transpositional reasons.

While chapter introductions explain his reasons for individual repertoire choices, Kaufman’s analysis revolves mostly around concrete lines, using commented games as his vehicle. He tends to propose variations that avoid the heaviest theory with White, while turning to two of the most professional of openings – the Breyer and Grunfeld – as the backbones of his Black repertoire.

In the Introduction Kaufman warns his readers that he omits “rare” responses from the opponent to save space and offer alternative ideas. This means that the book is unlikely to be refuted, but readers will have to do some extra work to flesh out their repertoires.

The analysis in Kaufman’s New Repertoire is heavily influenced by the computer, and individual lines are usually punctuated with numerical evaluations from Komodo. This is not to say that the book is perfect. Attributions of novelty status are sometimes incorrect, although that may have more to do with differing data sets than anything else. More worrisome are the analytical errors and omissions. Two examples:

(a) Kaufman recommends 8. Qf3 in the Two Knights, and after 1.e4 e5 2.Nf3 Nc6 3.Bc4 Nf6 4.Ng5 d5 5.exd5 Na5 6.Bb5+ c6 7.dxc6 bxc6 8. Qf3 he analyzes the two traditional mainlines of 8. … Be7 and 8. … Rb8. Checking his work, I discovered that neural net engines thinks sacrificing the exchange with 8. … cxb5 is fully playable, giving Black good compensation after 9. Qxa8 Be7 (Leela) or 9. … Qc7 (Fat Fritz). See the recent game Chandra-Theodoru from the SPICE Cup in 2019 for an example of the latter.

Jan Gustafsson made an analogous, and equally Leela inspired, discovery in his new (and outstanding) Lifetime Repertoire: 1. e4 e5 series for Chess24, analyzing 8. … h6 9. Ne4 cxb5 10. Nxf6+ gxf6 11. Qxa8 Qd7! where the best White can do is head for a perpetual.

While the idea of giving the exchange is considered inferior by theory, the fact that Leela approves it should have been just the kind of discovery that Kaufman would trumpet here. Perhaps he didn’t believe what he was seeing, although it should be noted that Komodo verifies Black’s compensation.

(b) After 1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.c3 Nf6 5.d4 exd4 6.e5!? d5 7.Bb5 Ne4 8.cxd4 Bb6 9.Nc3 0–0 10.Be3 Bg4 11.h3 Bh5 12.Qc2 we reach a “rather critical” position.

Here Kaufman discusses five moves: 12. … Bg6, 12. … Bxf3, 12. … Nxc3, 12. … Rb8, and 12. … Ba5!, which “may be Black’s only path to roughly equal chances.” (96)

I found two problems with the analysis, both involving Kaufman glossing over a poor move towards the end of a line, allowing him to claim an advantage for the side he is championing. After 12. … Bxf3, 18. … Nf5 is dubious; better is 18. … Ng6 as in Vocaturo-Moradiabadi, Sitges 2019. His analysis of 11. Qc2 is also flawed – check the pgn at uschess.org for more details. And these were not the only “tail-errors” I found in my study.

I’m torn on how to assess these analytical lapses. On the whole the book is well-researched and up to date, and the broad outlines of all Kaufman’s repertoire choices seem sound. So why are there these small problems, especially when the entire conceit of the book is its being computer-proofed, and with so many of the lines cribbed verbatim from the engine? I don’t have an answer to this, but I do wonder if Kaufman doesn’t suffer from a bit of confirmation bias.

As one of the co-authors of Komodo, Kaufman surely trusts the engine a great deal, but the version used here – Komodo MCTS – is markedly inferior to traditional Komodo or Stockfish, and is rated some 200 points lower on most testing lists. Komodo MCTS has the advantage of being able to analyze multiple lines at once without a performance hit, but its (very relative) tactical shallowness can be a concern. Because Leela suffers from similar issues, it may have been smarter to pair it with traditional Komodo instead.

Kaufman’s New Repertoire for Black and White is a solid repertoire offering despite these problems. His recommendations are well-conceived, and I was impressed with how much Kaufman was able to stuff into these pages. There’s not a lot of conceptual hand-holding here, so readers will have to be strong enough – say 2000 and above – to get maximum value from the book, and many lines will require supplemental study and analysis for the sake of completeness. Still, for those looking for a one-stop repertoire, particularly from the Black side, Kaufman’s book might be just what the doctor ordered.

Game Changer?

This review has been printed in the April 2019 issue of Chess Life.  A penultimate (and unedited) version of the review is reproduced here. Minor differences exist between this and the printed version. My thanks to the good folks at Chess Life for allowing me to do so.

—–

Sadler, Matthew, and Natasha Regan. Game Changer: AlphaZero’s Groundbreaking Chess Strategies and the Promise of AI. Alkmaar: New in Chess, 2019. ISBN 978-9056918187. PB 416pp.

Sigmund Freud once described the “three severe blows” suffered by human narcissism in the course of Western history.[1] The cosmological blow, struck by Copernicus, expelled us from our supposed place at the center of the universe. Darwin’s biological blow denied us the comfort of our separation from, and superiority over, the animal kingdom. And Freud himself landed the final, psychological blow, exposing the irrational unconscious forces beneath even the greatest achievements of human rationality.

To these three psychic wounds chess players can add a fourth: Garry Kasparov’s defeat at the hands of Deep Blue in 1997. Deep Blue’s victory was portrayed in the mass media as a referendum on human intelligence, a ‘canary in the coalmine’ moment in which the inevitable overtaking of human creativity by machine intelligence was made manifest.

Curious thing, though. What was imagined as an antagonistic relationship between man and machine has instead proven to be a constructive one. Sure, humans have given up trying to beat Stockfish or Komodo, even at odds, but our ‘metal friends’ (Tukmakov’s delightful turn of phrase) are now our trusted analytical partners and teachers.

Far from killing our game, chess in the e-sport era now depends on the presence of engines, which play the role of the hole-cam in the poker boom. They give the illusion of prescience, allowing amateurs the heady feeling that they know more than the players themselves.

So imagine the shock when a scientific pre-print appeared on the Internet in December 2017. Its title, “Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm,” was anodyne enough, but the paper announced a seismic shift in artificial intelligence and chess. AlphaZero, a program created by a Google subsidiary known as DeepMind, trounced Stockfish in head-to-head play. In doing so it forced us to rethink everything we know about computer chess.

The principles governing Stockfish’s play are not fundamentally different than those guiding Deep Blue, although they have been profoundly refined in the intervening years. Stockfish uses human-tuned criteria to evaluate each position in its search tree, and through “alpha-beta” search methods it is able to focus on promising continuations while pruning away inferior moves. Each move and each decision are the result of precise mathematical calculations, and human users can extract exact numerical evaluations for any given position.

AlphaZero is different, as Matthew Sadler and Natasha Regan lucidly explain in their new book, Game Changer: AlphaZero’s Groundbreaking Chess Strategies and the Promise of AI. Pre-programmed with only the basic rules of chess, and using general (non-specific) self-training algorithm, AlphaZero trained itself to play chess over the course of nine hours and 44 million self-play games. Periodically the program would refine its neural network, promoting tunable weights and network ‘layers’ that led to favorable outcomes, and demoting those that didn’t.

AlphaZero functions by combining these self-taught evaluative values with a Monte Carlo style tree search, where possible future game positions are spun out, evaluated, and ranked probabilistically. We don’t know exactly how AlphaZero decides what to play. The algorithm is a ‘black box’ in the Latourian sense, where inputs and outputs are known but (in contrast to Stockfish) its internal mechanisms remain opaque, even to DeepMind. What we do know is that AlphaZero is immensely, improbably strong, exhibiting an attractive attacking style reminiscent of Kasparov.

Perhaps this is what makes AlphaZero so remarkable – its style. What we see in its victories over Stockfish should, given all we know about computer chess, be impossible. Stockfish is typically seen as a calculative god and defensive wizard, able to soak up pressure, induce errors, and grind down its opponents. AlphaZero defeated it by playing the kinds of attacking, sacrificial ideas that, played by humans, would inevitably be refuted by the machine.

Sadler and Regan spend two chapters of Game Changer describing the technical aspects of AlphaZero’s self-training regiment, the way it “thinks,” and what its evaluations and expected scores mean. Their extensive access to the DeepMind team and the algorithm allow them to craft accessible explanations of difficult subjects, and the mini-interviews with DeepMind team members are helpful.

The meat of the book, however, focuses squarely on AlphaZero’s style. What makes it so good? How can we reverse-engineer the logic of its moves and apply that knowledge to our own games? By studying the roughly 230 publicly available AlphaZero games, along with approxmiately 2100 additional games provided by DeepMind, Sadler and Regan distill a number of tantalizing traits in AlphaZero’s play.

An example is useful. Consider this game, which Sadler describes as “perhaps AlphaZero’s most beautiful game of all.”[2]

NIMZO-ENGLISH (A17)
AlphaZero
Stockfish 8
AlphaZero v. Stockfish Match, 2017

1.Nf3 Nf6 2.c4 e6 3.Nc3 Bb4 4.Qc2 0–0 5.a3 Bxc3 6.Qxc3 a5 7.b4 d6 8.e3 Ne4 9.Qc2 Ng5 10.b5 Nxf3+ 11.gxf3 Qf6 12.d4!?

Sadler and Regan expected 12.Bb2 Qxf3 13.Rg1 but AlphaZero instead plays for long-term compensation.

12. … Qxf3 13.Rg1 Nd7 14.Be2 Qf6 15.Bb2 Qh4 16.Rg4!?

Giving up the h-pawn to open the file. Stockfish sees this position as better for Black, while AlphaZero thought that White had a slight advantage.

16. … Qxh2 17.Rg3 f5 18.0–0–0

Offering pawn number three!

18. … Rf7

After 18. … Qxf2 19.Rdg1 Rf7 20.R1g2 Qe1+ 21.Bd1 White’s compensation is undeniable.

19.Bf3 Qh4 20.Rh1 Qf6

image

What does AlphaZero have for the two pawns? Two half-open files and massively superior mobility. This is a key idea for Sadler and Regan. As they explained in a conference call for chess journalists – the first such promotional call I’ve been on for a chess book! – the concept of mobility is fundamental for understanding how AlphaZero plays. It works to maximize the mobility of its pieces and minimize the mobility of its opponent’s. One of AlphaZero’s most striking tendencies, the pushing of its rook pawns to restrict the opponent’s king, is emblematic in this regard. Here, having opened lines for its rooks, AlphaZero now proceeds to open diagonals and further increase its mobility.

21.Kb1 g6 22.Rgg1!? a4 23.Ka1 Rg7 24.e4 f4 25.c5 Qe7 26.Rc1 Nf6 27.e5 dxe5 28.Rhe1 e4 29.Bxe4 Qf8

This is a key position in both the game and the book. Sadler and Regan use it to illustrate AlphaZero’s “thought processes” in Chapter 4.

30.d5!

AlphaZero sacrifices another pawn to open the a1–h8 diagonal!

30. … exd5 31.Bd3! Bg4 32.f3 Bd7

White’s initative grows after 32. … Bxf3? 33.Rf1 Be4 34.Rxf4.

33.Qc3 Nh5 34.Re5

AlphaZero rates its winning chances at 80.3% here. (It evaluates positions by win percentage in Monte Carlo game rollouts.) Stockfish 8 thinks White is significantly better, but newer versions of the engine more clearly understand the danger.

34. … c6 35.Rce1 Nf6 36.Qd4 cxb5 37.Bb1 Bc6 38.Re6 Rf7

Stockfish hopes to return some of its material advantage and weather the storm. AlphaZero does not oblige.

39.Rg1 Qg7 40.Qxf4 Re8 41.Rd6 Nd7 42.Qc1 Rf6 43.f4! Qe7 44.Rxf6 Nxf6 45.f5 Qe3 46.fxg6 Qxc1 47.gxh7+ Kf7 48.Rxc1 Nxh7 49.Bxh7 Re3 50.Rd1 Ke8 51.Ka2 Bd7 52.Bd4 Rh3 53.Bc2 Be6 54.Re1 Kd7 55.Kb2 Rf3 56.Re5 Rg3 57.Re3 Rg2 58.Kc3 Rg4 59.Rf3 Ke8 60.Rf2 Rg3+ 61.Kb4 Rg4 62.Rd2 Bd7 63.Ka5 Rf4 64.Be5 Rf3 65.Rd3 Rf2 66.Bd1 Bc6 67.Kb6 1–0

One can’t help but feel as if a superior, alien intelligence has taken the White pieces and opened a new vista on to our beloved game.

Part III of Game Changer brilliantly distills some of the key features of AlphaZero’s attacking prowess. We see, through detailed analysis and clear explanation, how AlphaZero values outposts, why it rams ‘Harry the h-pawn’ forward, how it plays on color complexes and sacrifices for what Kasparov called quality. Part IV, devoted to AlphaZero’s opening choices, is less successful. The authors laud AlphaZero’s novel handling of the White side of the Carlsbad structure, for instance, but the game they cite departs from theory on the sixth move, rendering much of the fine preparatory explanation useless.

Game Changer is an excellent book, fully deserving of the critical praise it has received. Sadler and Regan patiently explain the technical minutia for a non-technical audience, and their attempts to divine the essence of AlphaZero’s style are clear and convincing. Until DeepMind succeeds in “recovering back” AlphaZero’s implicit heuristics through some secondary algorithm, this treatment is as good it gets.

What remains less settled, at least in my mind, is the issue of the book’s title. Is AlphaZero really a game changer? Does its advent herald a revolution in chess?

DeepMind’s novel computational solution – AlphaZero’s self-learned strength and style – is as disruptive today as Deep Blue’s brute force approach was in 1997. Both reconfigured our understanding the possibilities of computer chess and, truth be told, of chess itself.

This, unfortunately, does not exhaust the two project’s similarities. AlphaZero seems doomed to a life behind corporate bars much like its august predecessor, hidden away from the public in the interest of protecting trade secrets. And as with Deep Blue, AlphaZero’s influence on chess will be as a consequence be limited.

I suspect that the real game changer will be Leela Chess, an open-source project that mimics AlphaZero’s self-learning algorithm. Because it is open-source, like the now ubiquitous Stockfish, Leela can be used by anyone without cost. Players can train with Leela, use it to analyze their games, and test their ideas against it. The democratization of chess information that began with Robert Hyatt’s Crafty, Mark Crowther’s The Week in Chess, and Stockfish continues with Leela, and the chess world will be much the richer for it.


[1] See Freud’s Compete Psychological Works (Standard edition, ed. Strachey), volume 17, p.139-141.

[2] https://www.youtube.com/watch?v=0RuIHfNcPO0