How does a machine learn chess? Surprisingly, very much like a human being!

Updated: Jan 21

Written by Henri Jamet, ML Intern at Tom Capital AG and student at the Engineering School of Epita

Thanks to the success of the series “The Queen’s Gambit” many people joined the world of chess this year. Also, machines entered this world, relying entirely or partially on machine learning algorithms. In this article, we explain in seven steps how you and how the machine would learn the game of chess to help readers better understand how machine learning works in practice.

Get the data

First of all, you would learn about the subject, get books of openings and endgames, discover famous chess games and list the most frequent mate sequences.

The same goes for the machine. First, we get good data and explore it with graphs and statistical tools (correlation matrix, whisker box, combination of variables) to gain a first idea of the problem.

Make the data readable

You may be put off by the hard-to-understand algebraic notations used to describe chess moves. You could find a way to translate this data for yourself by watching videos of experts who will complete, relate, simplify and assess the importance of each piece of information.

In machine learning, a similar step consists in checking that the data is understandable by the machine, that it is not too noisy, incomplete, or worse, biased (Normalization, Imputers, Encoders...). For example, the algebraic notation of a chess move could be "bxc4" originally, which means "The bishop eats the piece on square C4". If we encode this information in a very reductive way by keeping only a binary score indicating if the move is a capture, we intuitively understand that our model would rather quickly find a positive correlation between the number of captured pieces and the score of the game.

Selecting a model

Each player has his/her style of play, his/her strengths, and weaknesses. You should choose your strategy according to your strengths and weaknesses and your opponent's game, which represents the problem you face.

There is a plethora of Machine Learning algorithms (Random Forests, Neural Networks, Regression, K-means...), each adapted to a given problem. It is important to understand the advantages and disadvantages of each of them to select the most suitable one for the problem you have to solve. For example, one can intuitively understand that a linear or polynomial model is ideal for predicting the probability of death of an individual as a function of his or her age, whereas a decision tree would be better suited to predicting less continuously correlated data, such as evaluating the probability that a number has of being prime as a function of the digits that make it up and their position.

Train and evaluate

Now you know how to play. It's time for you to play a few games and evaluate yourself to get an idea of your ELO or level.

This is the heart of the matter and the simplest and shortest part: our model will have to learn from the data we have collected for it. We can then evaluate its results and detect possible problems (Over/UnderFitting, cross-validation...).

Fine-tuning our algorithm

Now that you have identified your weaknesses, you can employ targeted exercises to address them and focus on your most frequent errors while continuously building on your strengths.

In Machine Learning, we can now try to remedy the weaknesses of our model by looking for the best combination of parameters (Grid Search), by adjusting the training data (Data Augmentation), or by using other strategies during the training (Dropout, Regulation, Early Stopping...).

Test in real conditions

You have become a formidable player, on paper. But what about the pressure of tournaments, timed games, opponents ready to do anything to win? You now do want to play in a tournament to make sure you're good enough!

As good as a model may be in theory on training data, it is rarely as good in reality. To get a real idea of its ability to generalize, we now have to evaluate it against data it has never seen before and which is preferably very different from the training set. Only then will we know if our efforts have paid off. Take for example the prediction of the price of a financial asset. Your model could simply "memorize" the market value for any given date during training, which would ensure a 100% success rate. However, as you can imagine, its performance under real conditions might not be so exceptional.

Integrate with a decision algorithm

Are your exceptional chess skills working for you in tournaments, too? Maybe you should think of a way to apply them such as becoming a champion.

We have only dealt with the submerged part of the iceberg. Now we need to find a way to use the results of our model in a way that is understandable to us (to detect possible errors), easy to maintain, and with a method that can be applied in the real world. It is quite possible to create a model that learns to play chess by predicting the move to be played as a function of the game state. However, this would mean blindly trusting the model by not post-processing its predictions. If the move results in a defeat, it will be almost impossible to understand the reasons for this failure, apart from the fact that this model would be too general and would have many difficulties in learning. It is more interesting to train a model to evaluate a position and have a second set of classical algorithms (AlphaBeta pruning, transposition table, quiescence) iterate over the possible positions to determine the best move to make.


We have seen in this article that the steps of training for humans and machines are quite similar. However, the word "training" for a machine describes a much more complex process than one might initially think. Each of the steps listed above is a mandatory passage with several pitfalls and varies drastically from one data set to another. The slightest error in data processing could cause the model to predict completely wrong results, a wrong choice of model would lead to a significant drop in performance, a biased test would give a completely wrong idea of model accuracy, or a suboptimal choice of prediction would lead to a loss of information and so forth.

Despite these problems, AI is now a must-have in a variety of fields, and its capabilities, once mastered and understood, are very powerful. This is not surprising, as we now know that from a more abstract point of view, a machine learning model is nothing more and nothing less than a way to find the best mathematical solution to a given problem based on the data provided.

Tom Capital AG is an investment boutique that applies machine learning to the entire investment process, from data selection to portfolio construction. Do not hesitate to contact us at for more information or inquiries.

188 views0 comments