Thursday, July 7, 2016

Chess engines

I find chess engines, and how they have advanced in just the last ten years, really fascinating.

In 1997 the chess computer Deep Blue gained a lot of notoriety for being the first computer to beat a world-reigning chess master, Garry Kasparov, in a tournament of several games with long time controls. (More specifically, 6 games were played, and the score was 3½–2½ in favor of the computer.)

Since then, however, chess engines have advanced in major leaps.

Note that Deep Blue was a dedicated computer for the sole purpose of playing chess. It could calculate approximately 200 million nodes (ie. chess positions) per second.

Modern top chess engines will run on a regular PC, and their calculation speed on such a PC, even when using eg. 4 cores, is less than 10 million nodes per second, only a small fraction of what Deep Blue was capable of. Yet these modern chess engines, running on a regular PC, are significantly stronger than Deep Blue was, and would easily beat it (and even the strongest chess grandmasters.)

The reason for this is that their search tree pruning and position evaluation functions (and other more minor things) have vastly improved during the last 20 years. They are capable of finding the best moves with significantly less work than Deep Blue was. (It has been estimated that even Deep Blue back in 1997 would have got something like 200 ELO points stronger with some simple modern changes in its pruning functions, which would have made it significantly stronger than Kasparov.)

Modern chess engines do indeed find very easily moves that the best chess engines of just ten years ago would have struggled with (not to talk about engines of 1997). Consider, for example, this position from game 6 of the Kasparov vs. Deep Blue tournament:


Deep Blue is playing white, and Kasparov, as black, has just played h6. What is white's best response?

h6 is, in fact, a bad move. However, seemingly Kasparov played it to try to trick Deep Blue, because the proper response is so difficult that no chess engine of the day would play it. Deep Blue played the correct move, but only because it was in its opening book, not because it calculated it by itself. No engine of the time (or probably even for ten years since) would have found the correct response on their own.

The best move is Nxe6. This is a pure knight-for-pawn sacrifice because there is no immediate regaining of the lost material. It's done purely for positional advantage. It was extremely hard for chess engines to see this move as good, because at first it seems like a pure loss of material with no apparent advantage.

Yet, if you give this position to a modern top chess engine, like Stockfish 6, to analyze (with no opening books or anything), they will find Nxe6 in less than a second.

Or consider this position from the so-called "Kasparov Immortal" game (Kasparov vs. Topalov, 1999):


Black (Topalov) has just played Qd6. What is the best response by white?

The best response by white, and what Kasparov played, is the Rxd4 sacrifice.

I watched a YouTube video something like ten years ago about this game, and the person analyzing the game said that he gave this position to one of the top chess engines of the time (I don't remember which), and it took it over an hour to find Rxd4 as the best move.

If I give that position now to Stockfish to analyze, it finds Rxd4 as the best move in less than a second.

That's not to say that modern chess engines find the solution to all possible problems so fast, even today. For example, consider this very hard and contrived problem: White to play, mate in 6:


While Stockfish extremely quickly evaluates this as being overwhelmingly favorable to white, it nevertheless takes it between 4 and 5 minutes on my computer to find the mate in 6. (Note that it's not specifically mate-searching, just analyzing the position. It might find it faster if it were set to mate-searching.)

Chess engines have become so strong that they easily beat even the strongest human players, even when run on regular PCs rather than dedicated hardware.

No comments:

Post a Comment