Artificial intelligence (AI) and machine learning are two hot topics not only within the IT world.
An activity that has recognized and still greatly recognizes artificial intelligence technologies as important tools is the game of chess, especially at expert levels.
Since the release of some of the top chess engines, AI has had a tremendous impact on the way top players set up their strategies. Virtually all top Grandmasters (who have FIDE ratings above 2700) use AI tools extensively to analyze their games and consequently play moves from chess engine recommendations.
In this article, we are going to analyze the importance of AI mechanisms to chess and discuss four of the best-known chess engines: Stockfish, AlphaZero, Leela Chess Zero, and the most recent engine, Mittens. We will look at how they are built and which strategies they apply to get the job done: winning.
The importance of artificial intelligence in the world of chess
In chess, artificial intelligence and chess engines specifically play a significant role in helping chess players analyze and improve their moves.
AI is fundamental in chess engines because it allows the computer to evaluate positions and make informed decisions based on its analysis. Chess engines use various algorithms and techniques, including machine learning, to evaluate positions and carry out the next move. They do this by analyzing vast amounts of data to come up with very solid and accurate position choices, allowing them to play much faster than a human could. This makes it a valuable tool for chess players who want to study and improve their play. Better yet, chess engines can also work at professional levels, making it a challenging opponent for even the strongest human players. So how exactly does the AI behind chess engines work?
Chess engines evaluate the best moves by using several powerful AI algorithms and techniques, including:
- Search algorithms: algorithms used to search through the vast number of possible moves and positions in a given turn. They look at the current position, generate all the possible moves, and then evaluate each resulting position to determine which move leads to the best outcome.
- Evaluation functions: functions that can evaluate the strength of a given position. They take into account factors such as material balance, pawn structure, mobility, king safety, control of key squares, among others. The evaluation function provides a numerical score for a given position, which the search algorithm uses to determine the best move.
- Endgame tablebases: precalculated databases that allow chess engines to play perfect endgame positions. When the engine detects that a position is an endgame position, it can use this database to determine the best moves.
- Machine learning techniques: techniques used to improve the evaluation functions of chess engines. They can learn from the results of previous games to improve their understanding of good and bad positions and adjust the weight of various factors in the evaluation function.
In terms of strategy, chess engines can be programmed to play in various styles depending on the preferences of the programmer or the user. For example, some engines might be designed to play aggressively and prioritize attacking the opponent’s king, while others may be designed to play more cautiously and prioritize material advantage and king safety. The choice in strategy will often depend on the evaluation function and the weight assigned to various factors.
The most famous and esteemed chess engines thus far use a combination of search algorithms, evaluation functions, endgame tables, and machine learning to evaluate the best moves and decide their strategy. The quality and strength of a chess engine will depend on the sophistication of these algorithms and techniques along with the accuracy of the evaluation function.
Now let’s briefly analyze four of the most famous chess engines.
Stockfish
Stockfish (https://stockfishchess.org/) is an open-source, UCI-compatible (meaning Universal Chess Interface, a protocol for communicating with chess engines in a standardized way) chess engine that is widely regarded as one of the strongest chess engines in the world. It is written in C++ and is designed to run on a variety of platforms, including Windows, Mac, and Linux.
In terms of its strength, Stockfish is known for its ability to thoroughly and accurately analyze positions. As a result, it has consistently been rated at the top of computer chess ratings and has won several computer chess championships.
Stockfish uses a combination of advanced AI algorithms to examine and evaluate positions, including:
- Alpha-Beta Pruning: a search algorithm that reduces the number of nodes in the search tree by pruning branches that are unlikely to contain the best move. This allows the engine to search the different move choices in the same amount of time.
- Quiescence Search: an extension of the alpha-beta search that deals with the problem of tactical positions. When found in these scenarios, quiet moves (or rather moves that do not capture material) may not be good enough to avoid future tactical positions accurately, so the engine needs to continue searching for possible tactical moves that could follow until the position is without a doubt, truly quiet.
- Null Move Pruning: a technique that allows the engine to quickly identify positions where a side has no useful moves. In these positions, the engine can simply pass the move to the opponent, making it possible to take a better look at move choices in a shorter amount of time.
- Multi-Threading: an algorithm designed to take advantage of multi-core processors, with each core handling a separate portion of the search tree. This allows the engine to search faster and analyze more positions in a given amount of time.
We can label Stockfish as a “traditional chess engine,” which is trained by using large databases of Grandmaster games to guide their evaluation and decision-making through the aforementioned AI strategies.
Stockfish’s source code is publicly hosted on Github, and you can find it here: https://github.com/official-stockfish/Stockfish,released under the GPL (GNU General Public License).
AlphaZero
AlphaZero is a chess engine developed by DeepMind, an AI research company acquired by Google.
Written in C++ and Python and not publicly available, AlphaZero became famous for its quick mastery of the game after only a few hours of self-play training.
It uses a combination of deep neural networks and Monte Carlo Tree Search (MCTS) to play chess. The neural networks are trained to evaluate positions and predict the best move to make while the MCTS algorithm is used to search for the best move by simulating many random games from a given position. The neural networks and MCTS algorithms are trained together, allowing AlphaZero to improve both its ability to examine positions and its search capabilities.
The key difference between AlphaZero and Stockfish is the way they consider positions and choose the next move. Stockfish uses a traditional, rule-based evaluation function that takes into account factors such as material balance, control of the center, and king safety. AlphaZero, on the other hand, uses a deep neural network that is trained to predict the outcome of the game from a given position by recognizing patterns that are important to succeed.
AlphaZero uses MCTS, which is a probabilistic search algorithm that simulates many random games from a given position and uses the results to guide its search. MCTS allows AlphaZero to explore a much wider range of possibilities, making it less prone to being misled by tactics and more likely to find the best move.
As already mentioned, after only four hours of self-play training AlphaZero was able to beat the world’s best chess engine, Stockfish, in a series of 100 games, with 28 wins, 72 draws, and 0 losses. This was a remarkable accomplishment and demonstrated the power and effectiveness of AlphaZero’s AI-based approach to playing chess.
AlphaZero’s quick mastery of chess after only a few hours of self-play training highlights the potential of deep reinforcement learning and AI in general, and it has inspired further research and development in this game.
Leela Chess Zero
Leela Chess Zero (LC0) is an open-source, artificial intelligence-based chess engine that utilizes the principles of deep learning and reinforcement learning. It was inspired by AlphaZero.
LC0 is written in a combination of C++ and CUDA, a parallel computing platform and application programming interface (API) for using graphics processing units (GPUs) to perform general purpose calculations.
LC0 uses neural networks to evaluate positions and make decisions. The neural networks are trained using a process of self-play, where the engine plays games against itself and adjusts its parameters based on the outcome of those games. This allows LC0 to improve over time and become a stronger chess player. The process of self-play and reinforcement learning is implemented using a variety of algorithms, including Monte Carlo Tree Search (MCTS) and temporal difference learning.
Mittens
Mittens was an AI bot chess engine released some weeks ago by the popular Chess.com as a part of five cat-based chess engines.
Appearing as both a cute and innocent cat within his UX, the engine of Mittens trash talks the opponent with a selection of voice lines, including quotes from Robert Oppenheimer, Vincent van Gogh, Thanos, and Friedrich Nietzsche.
Even though it looks like an engine with an Elo rating of 1, Mittens is very strong and is able to win 99% of the multiple millions of games it has played against human players. Its real Elo is thought to be around 3200-3500 points (top GMs have around 2700-2800 Elo points), since it can defeat AI bots around this level but not Stockfish 15, a 3700-rated engine.
Thanks to the public hype given by popular chess players and streamers, like the top GM Hikaru Nakamura, the engine soon became viral, dramatically increasing the traffic towards the website. In January, 40% more games were played compared to the monthly average, leading to database issues relative to the scaling process. In February, Chess.com, for the moment, removed Mittens and the other cat engines and replaced them by five other engines powered by artificial intelligence. Chess.com stated that they would have to upgrade their servers and invest more in cloud computing to solve the problems caused by the website’s surge in popularity.
There is no specific information available on the technologies with which this chess engine was created, even if some speculations indicate that it could have been built on top of Komodo, a UCI chess engine written in C and C++ whose strength is comparable to that of the engines previously discussed.
Cons of AI in chess
Although AI has brought great advantages to the world of chess, many chess lovers have been unhappy with this revolution. Some players feel that the game has become less creative, as the first 15-20 moves of a game are now usually taken from well-known, winning openings previously analyzed with a chess engine. Indeed, the former world champion Vladimir Kramnik affirmed that by now the creativity of the game has largely left room for memorizing moves, arguing, “You don’t even play your own preparation, you play your computer’s preparation.”
More articles about AI and Machine Learning
Will ChatGPT Change how we Study and Search on the Web?
AI trends in Software Development for 2023
GitHub Copilot: Voices for and Against