Chessable Research Awards Fall 2023 Winner: Using Machine Learning to Value Chess Pieces and Squares

·

Table of Contents

The Chessable Research Awards for the Fall 2023 cycle had two winners, undergraduate student Aditya Gupta and graduate student Denise Trippold.

In this guest blog post, Aditya Gupta discusses the research he did with Dr. Nick Polson, Dr. Vadim Sokolov, and FIDE Trainer Shiva Maharaj. When Aditya received his Chessable Research Award, he was pursuing dual enrollment in mathematics through the University of Illinois. For the spring of 2024, he is matriculating as an incoming freshman in computer science at Stanford University. Contact Aditya at [email protected]

Using Machine Learning to Value Chess Pieces and Squares

By Aditya Gupta

Introduction

Beginner chess players often value their trades and moves through the lens of commonly accepted point values: king as infinite, queen as 9, rook as 5, bishop as 3, knight as 3, and pawn as 1. Yet a knight in the center of a chess board is usually worth more than a knight in the corner. Trading these knights isn’t a fair trade, despite the points exchanged being equal. This begs the question: how does the relative value of a chess piece change as the square it is on changes? More specifically, we attempt to figure out the combined valuation of a piece and the square that it is on. By the end of this blog post, we will have created a method to determine the valuation of different piece-square states, such as a white knight on f5 or a black bishop on b7.

Combining both a piece and a square creates hundreds of different states that need to be evaluated. The expert-led analysis that led to the creation of the commonly accepted point values may not be applied to these states. We use Machine Learning methods to help us analyze large datasets of chess games to empirically determine the valuations of different piece-square states.

By being able to marginally value the chess square and not just the chess piece, chess players may be better able to determine and analyze the effectiveness of piece placement, improving their overall chess game.

Literature Review

We first read about work done in Chess AI and traditional Machine Learning (ML) models. We particularly focus on neural network methods to analyze or value some aspects of the game of chess.

Recently, a chess study used machine learning techniques to value different chess gambits, not just based on Stockfish’s objective evaluation, but also through an ML analysis of the skewness and volatility in each gambit. For example, certain gambits are harder to play against due to the theoretical knowledge needed, and thus, may be good practical choices during games. This approach of using Q-learning/Game Theory ideas to value gambits is novel and may be seen as the early predecessors of ML-based Game Theoretic analysis in chess.

Additionally, recent transfer learning models have also used ML techniques to identify style components of various chess players, which requires the evaluation of different playing styles. Such approaches, when coupled with other ML techniques like the one in this blog post, may help chess players better improve their gameplay.

A few ML-based methods have been used to determine the value of the chess pieces from online chess games. For example, in a recent chess blog, Logistic Regression was used to calculate the value of the chess pieces. In such studies, the values of the chess pieces were determined by using the existing piece imbalances in the game to predict the result of the game. Such approaches have generally been found to be very interesting, and the results of only determining piece valuation (without any information about the square it is on) led to values very similar to the standard piece values.

Experimental Design

To figure out the relative valuation of a piece-square state, we must concretely determine what that valuation means. The currently accepted point-value system arbitrarily values a pawn at 1 point and defines the relative value of all the other pieces relative to the pawn. Thus, a knight, which is typically 3 points, may also theoretically be the same value as 3 pawns.

We define the valuation of a piece-square state in a more meaningful way. For a given state, W(Piece, Square) is defined to be the probability that a player will win a given chess game given that they have the given piece on the given square. For example, W(White Rook, h5) is the probability that the White player will win the game if they have a rook on the h5 square. Similarly, W(Black Knight, f4) is the probability that Black will win the game given that Black has a knight on the f4 square. Thus, we now define our problem as defining a methodology for determining the value of W(Piece, Square).

First, we must procure our data. We first collect 2000 chess games played between chess grandmasters. A computer algorithm then goes through each game, aggregating each of the piece-value pairs that exist in every position in each of the chess games. For each piece-value pair, we also store the corresponding centipawn evaluation (measured by the Stockfish Chess Engine), creating a database of Piece-Square states and the centipawn evaluation. The centipawn evaluations can then be used to calculate the winning probability of that state according to the formula in Figure 1:

Figure 1: Formula to convert centipawn to w(s)

Thus, we now have a complete dataset of Piece-Square states and their corresponding W(s) values. We now design and train a neural network architecture to predict W(s) for any state s.

We train a layered neural network to predict the value of W(s). We design a 3-layer Neural Network that takes in the state s information (the piece, the color, and the square), and outputs W(s). The model is trained for 100 epochs and is also hyperparameter-tuned to ensure its accuracy.

Results and Discussion

In this blog post, we analyze the results of our methods by analyzing the value of the white knight on various squares of the chessboard in grandmaster games. The presented methodology may also be extended to other pieces and game characteristics, such as for analyzing the value of pawns in different parts of a chess board, or when bishops are in fianchettoed positions.

We give our model the input s = White Knight and compute the predictions for all 64 squares of the chessboard. The results are shown in a heatmap in Figure 2. For each square, the probability stated shows the predicted percentage of games that the White player will win if they have a white knight on that square. For example, games that have a white knight on the f5 square are predicted to end in a win for the White side 59% of the time, while games that have a white knight on the a1 corner typically end in a win only 46% of the time.

Figure 2. W(s) Calculated for the White Knight

Such predictions allow us to determine what set of squares may generally be seen as the most and least optimal for a given piece. We further computed these results for all other pieces and found many common chess maxims (such as pawns on the edges are less valuable than if they are in the center) reflected in our predictions.

Through this project, we hope to show a new methodology of advancing ML use in chess, giving emerging players and chess aficionados better ways to analyze and improve their gameplay. Additionally, by showing and formalizing that different chess squares have different values, we encourage both experts and beginners alike to recognize the power of optimal piece placement and to make that a part of their valuation system when deciding to trade and move their pieces.

References

Botvinnik, M. M. (1970). Computers, chess and long-range planning.

Clifton, J., & Laber, E. (2020). Q-learning: Theory and applications. Annual Review of Statistics and Its Application, 7, 279-301.

Good, J. (1988). A five year plan for automatic chess (excerpts). In Computer Chess Compendium (pp. 118–121).

McIlroy-Young, R., Wang, R., Sen, S., Kleinberg, J., & Anderson, A. (2022, August). Learning models of individual behavior in chess. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (pp. 1253-1263).

Nimzowitsch, A. (2022). My System. Open Road Media.

Pascutto, G. C., Linscott, G., Lyashuk, A., & Huizinga, F. (2022). Leela chess zero. Retrieved from https://lczero.org. Accessed: 13 April 2022.

Turk, C., Polson, N., & Maharaj, S. (2021). Gambits: Theory and Evidence. arXiv e-prints, arXiv-2110.

Ubdip. (2022b). Finding the value of pieces. Lichess Blog.

Interested in research?

The Chessable Research Awards are for undergraduate and graduate students conducting university-level chess research. Chess-themed topics may be submitted for consideration and ongoing or new chess research is eligible. Each student must have a faculty research sponsor. For more information, please visit https://www.chessable.com/research_awards

Was this helpful? Share it with a friend :)

4.9 with 3.65K user reviews

Check them on individual course pages