Chess

How AI Revolutionised the Ancient Game of Chess

AI has fundametally changed the way we play and think about chess – a game that dates back almost 1,500 years. But how do chess engines work?

I have come to the personal conclusion that while all artists are not chess players, all chess players are artists.Marcel Duchamp

‘Chaturanga’ – The Beginning

Chess dates back almost 1,500 years, with the precursors of the game originating in India in the 6th century. Originally called Chaturanga, the game was set on an 8x8 Ashtāpada board and shared two key fundamental features that still distinguish the game today. Different pieces subject to different rules of movement and the presence of a single king piece whose fate determines the outcome. But it was not until the 15th century, with the introduction of the queen piece and the popularization of various other rules, that we saw the game develop into the form we know today.

The emergence of international chess competition in the late 19th century meant that the game took on a new geopolitical importance. The Soviet Union devoted great resources to cultivating chess talent and dominated the game during this period. However, this dominance was to be disrupted, not by a citizen of another country, but by Deep Blue, an IBM computer.

Deep Blue – The Rise of the Machines

On the 11th of May 1997, Deep Blue made history as the first computer to beat a world champion, Garry Kasparov, in a six game match under standard time controls. Chess was a game that, for a long time, was considered to be too complex to be mastered by machines. It is not difficult to understand why this was thought to be the case. Claude Shannon, an American Mathematician, estimated in 1950 (to demonstrate the impracticality of solving chess by brute force) that there are more than 10^(120) possible unique games. To put this into context, the human body contains approx. 10^(27) atoms and there are an estimated 10^(78) atoms in the known universe.

So, it wasn’t surprising when Kasparov refused to believe the validity of his defeat, arguing that the computer must have been controlled by a real Grandmaster. Today, however, the ‘Man vs Machine’ debate is over, with advanced chess engines undisputedly trumping even the best Grandmasters this planet has to offer. Modern chess engines can broadly be classified into two categories: Traditional Engines and Neural Network Engines.

Traditional Engines – When Human Minds and Computing Power Meet

Stockfish, an open source chess engine developed by a large community of enthusiasts and developers, is perhaps the most widely used and strongest traditional engine out there today. But how does a traditional engine like Stockfish work and what makes it so powerful?

Stockfish Chess Engine Logo
Stockfish, first released in 2004, is consistently ranked near the top of most chess engine rating lists.

The complexity of traditional engines has evolved immensely over time, however, ultimately they do two important things:

1) Position Evaluation

Engines will evaluate positions and determine which position/side is better. The engine will provide a number that helps gauge the extent of dominance. A positive number means White has the advantage, while a negative number means Black is better. Engines will base this evaluation on a variety of different factors including:

  • The material on each side – all else equal, you would far rather be on the side that still has its queen
  • The safety of the king
  • The structure of the pawns
  • Whether you have a rook on an open file
  • Whether you have a bishop pair
  • …and many more

The below position is evaluated as a +3 (which essentially translates to White winning by the equivalent of 3 pawns), even though the material is even.

Chess Board Position with Even Material
Material is even but White is evaluated as having a 3 pawn advantage in this position.

2) Search Algorithms

Just as a Grandmaster would, engines try to look deeply into the position, evaluating the positions that result from certain moves in order to determine the best course of action. You can think of this process as a decision tree with each possible move generating a different branch to evaluate. The strength of an engine comes from its ability to evaluate far deeper than the human mind. Although it depends on the nature of the position, a Grandmaster may be able to calculate positions at a maximum depth of 10 -20 moves. Depending on the length of time allowed, modern engines can evaluate positions at an incredible depth of more than 50 moves.

As you can imagine, evaluating all possible moves and replies quickly becomes computationally impractical, even for the most powerful of machines. So instead, engines use ‘pruning’, evaluating the most promising lines and ignoring the ones that are obviously poor.

It is this combination of intelligent search algorithms and complex evaluation functions that makes engines so powerful at finding the best possible moves. And the more powerful the CPU, the better the engine becomes.

Neural Network Engines – Practice Makes Perfect

AI calculation

AlphaZero, developed in 2017, was the first neural network (NN) engine. It was an engine, that in some ways, was much weaker than Stockfish, evaluating just 1/100th as many moves per second as its opponent. However, AlphaZero was, at its core, an entirely different animal (the ‘zero’ meaning no human knowledge input). Contrary to traditional engines, instead of deducing the best moves with an algorithm designed by experts, AlphaZero – equipped only with the basic rules of chess and trained through reinforcement learning – gradually developed its own strategy by repeatedly playing games against itself.

Where traditional engines have typically used what is called an alpha-beta (AB) minimax search, where only the best possible moves are evaluated; NN engines choose to use Monte Carlo tree search (MCTS), where the best move is selected based on the probable outcomes of many playouts. To put it simply, an NN engine plays millions of quick games against itself with random moves and looks at the moves that seem to have the highest odds of winning.

Stockfish vs AlphaZero – Battle of the Machines

So which type of engine is more powerful? When AlphaZero met Stockfish 8, it promised to be a monumental clash. AlphaZero was trained for 4 hours prior to the showdown (the equivalent of millions of games). In 100 games, AlphaZero did not lose. It achieved a resounding victory (winning 28 games and drawing the rest). The game featured some dazzling long term sacrifices, perfect positional play, and a beautiful attacking style that was completely new to the world of computer chess. If you’re interested, here’s a recap of some of the games.

Re-defining the Game – The Influence of Engines

Humans have gotten better at chess over time as they diligently learn from the combined wisdom of past players. Studying openings, end games and key positions from opponents has long been part of the game. But there is no doubt that computers have accelerated this progress, as the top players today extensively use chess engines to analyse positions and generate ideas. We are seeing an increasing number of wild lines, brave sacrifices, hidden tactics and attacking play than ever before. There were genuine concerns that AI would ruin chess, but most would argue that it’s actually making the game beautiful again.

Enjoyed this read?

Stay up to date with the latest AI news, strategies, and insights sent straight to your inbox!

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
LET’S TRY!

Don’t wait get started now!

Build a custom website without the stress, easily customised to suit you.