Chess pieces: names and possible moves. Correct names of chess pieces

Read by Andrew Ng on Coursera. After getting acquainted with the methods discussed in the lectures, I wanted to apply them to some real problem. I didn’t have to search for a topic for a long time - optimization of my own chess engine simply suggested itself as a subject area.

Introduction: about chess programs

We will not delve into the architecture of chess programs in detail - this could be the topic of a separate publication or even a series of them. Let's consider only the most basic principles. The main components of almost any non-protein chess player are search And position assessment.

The search is an enumeration of options, that is, iterative deepening through the game tree. The evaluation function maps a set of positional features onto a numerical scale and serves as an objective function for finding the best move. It is applied to the leaves of the tree, and is gradually "returned" to the original position (the root) using the alpha-beta procedure or its variations.

Strictly speaking, real the score can only take three values: win, loss or draw - 1, 0 or ½. According to Zermelo's theorem, for any given position it is uniquely determined. In practice, due to the combinatorial explosion, not a single computer is able to calculate options down to the leaves of the full game tree (exhaustive analysis in endgame databases is a separate case; 32-piece tables will not appear in the foreseeable future... and in the foreseeable future, most likely, Same). Therefore, programs work in the so-called Shannon models- use a truncated game tree and an approximate estimate based on various heuristics.

Search and evaluation do not exist independently of each other, they must be well balanced. Modern search algorithms are no longer a “dumb” search of options; they include numerous special rules, including those related to position evaluation.

The first such search improvements appeared at the dawn of chess programming, in the 60s of the 20th century. We can mention, for example, technology forced version (FV)- extension of individual search branches until the position “calms down” (checks and mutual captures of pieces end). Extensions significantly increase the tactical vigilance of the computer, and also lead to the fact that the search tree becomes very heterogeneous - the length of individual branches can be several times greater than the length of neighboring, less promising ones. Other search improvements, on the other hand, are cutting off or search abbreviations- and here, among other things, the same static assessment can serve as a criterion for discarding bad options.

Parameterization and improvement of search using machine learning methods is a separate interesting topic, but for now we will leave it aside. Let us deal only with the evaluation function for now.

How does a computer evaluate a position?


A static estimate is a linear combination of various position attributes taken with certain weighting coefficients. What are these signs? First of all, the number of pieces and pawns on both sides. The next important sign is the position of these figures, centralization, occupation of open lines and diagonals by long-range figures. Experience shows that taking into account only these two factors - the amount of material and the relative value of the fields (fixed in the form of tables for each type of figure) - in the presence of a high-quality search can already ensure the strength of the game in the range of up to 2000-2200 Elo points. This is the level of a good first class or candidate master.

Further refinement of the assessment may include more and more subtle signs of a chess position: the presence and advancement of passed pawns, the proximity of pieces to the position of the enemy king, his pawn cover, etc. The legendary "Kaissa", the first world champion among programs (1974) had an assessment a function of several dozen features. All of them are described in detail in the book “The Machine Plays Chess,” a bibliographic link to which is provided at the end of the article.


One of the most sophisticated evaluation functions was that of the Deep Blue machine, which became famous for its matches with Kasparov in 1996-97. (For a detailed history of these matches, see a recent series of articles on Geektimes.)

It is widely believed that Deep Blue's strength was based solely on its colossal speed of iteration. 200 million positions per second, full (without cutting) search for 12 half-moves - chess programs on modern hardware are just approaching such parameters. However, it wasn't just about speed. In terms of the amount of “chess knowledge” in the evaluation function, this machine was also far superior to everyone else. The Deep Blue evaluation was implemented in hardware and included up to 8000 different features. Strong grandmasters were brought in to adjust its coefficients (it is reliably known that they worked with Joel Benjamin; David Bronstein played test games with different versions of the machine).

Without having such resources as the creators of Deep Blue, we will limit the task. Of all the characteristics of a position taken into account to calculate the score, let’s take the most significant one - the ratio of material on the board.

Cost of figures: simplest models

If you take any chess book for beginners, immediately after the chapter explaining the chess moves there is usually a table of the comparative values ​​of the pieces, something like this:
The king is sometimes assigned a final value that is obviously greater than the sum of all the material on the board - for example, 200 units. In this study we will leave His Majesty alone and will not consider kings at all. Why? The answer is simple: they are always present on the board, so their material assessments are mutually subtracted and do not affect the overall balance of power.

The figures' values ​​shown should only be considered as some basic guidelines. In reality, pieces can become “more expensive” and “cheaper” depending on the situation on the board, as well as on the stage of the game. Combinations of two or three pieces - one's own and the enemy's - are usually considered as a first-order amendment.

This is how the third world champion assessed various combinations of material in his classic “Textbook of Chess”:


From the point of view of general theory, the bishop and knight should be considered equally valuable, although, in my opinion, the bishop in most cases turns out to be a stronger piece. Meanwhile, it is considered completely established that two bishops are almost always stronger than two knights.

A bishop in a game against pawns is stronger than a knight, and together with pawns it also turns out to be stronger against a rook than a knight. The bishop and rook are also stronger than the knight and rook, but the queen and knight can be stronger than the queen and bishop. A bishop is often worth more than three pawns, but the same can rarely be said about a knight; he may even be weaker than three pawns.

A rook is equal in strength to a knight and two pawns or a bishop and two pawns, but, as stated above, a bishop is stronger than a knight in a fight against a rook. Two rooks are slightly stronger than the queen. They are slightly weaker than two knights and a bishop and even weaker than two bishops and a knight. The strength of the knights decreases as pieces are exchanged on the board, while the strength of the rook, on the contrary, increases.

Finally, as a rule, three minor pieces are stronger than the queen.

It turns out that most of these rules can be satisfied by remaining within the linear model and simply slightly shifting the values ​​of the figures from their “school” values. For example, one of the articles provides the following boundary conditions:

B > N > 3P B + N = R + 1.5P Q + P = 2R
And the values ​​that satisfy them:

P = 100 N = 320 B = 330 R = 500 Q = 900 K = 20000


The names of the variables correspond to the designations of the pieces in English notation: P - pawn, N - knight, B - bishop, R - rook, Q - queen, K - king. The values ​​here and below are indicated in hundredths of a pawn.

In fact, the given set of values ​​is not the only solution. Moreover, even non-compliance with some of the “inequalities to them. Capablanca" will not lead to a sharp drop in the strength of the program's playing, but will only affect its stylistic features.

As an experiment, I conducted a small match-tournament of four versions of my GreKo engine with different weights of pieces against three other programs - each version played 3 matches of 200 games with ultra-short time control (1 second + 0.1 sec per move). The results are shown in the table:

Version Pawn Horse Elephant Rook Queen vs. Fruit 2.1 vs. Crafty 23.4 vs. Delfi 5.4 Rating
Greko 12.5 100 400 400 600 1200 61.0 76.0 71.0 2567
GreKo A 100 300 300 500 900 55.0 69.0 73.0 2552
GreKo B 100 320 330 500 900 57.0 71.0 64.0 2548
GreKo C 100 325 325 550 1100 72.5 74.5 69.0 2575
We see that some variations in the weights of the pieces lead to fluctuations in the strength of the game in the range of 20-30 Elo points. Moreover, one of the test versions showed even better results than the main version of the program. However, it is premature to say unequivocally about the strengthening of the game with such a small number of games - the confidence interval for calculating the rating is a comparable value of several tens of Elo points.

The “classical” values ​​of chess material were obtained intuitively, through the chess players’ understanding of their practical experience. Attempts were also made to put some kind of mathematical basis under these values ​​- for example, based on the mobility of figures, the number of fields that they can keep under control. We will try to approach the issue experimentally - based on the analysis of a large number of chess games. To calculate the values ​​of the figures we will not need an approximate assessment of positions from these games is only their results, as the most objective measure of success in chess.

Material superiority and logistic curve

For statistical analysis, a PGN file was taken containing almost 3000 blitz chess games between 32 different chess engines, ranging from 1800 to 3000 Elo points. Using a specially written utility, a list of material relationships that appeared on the board was compiled for each game. Each ratio of material did not enter the statistics immediately after capturing a piece or promoting a pawn - first there had to be reciprocal captures or several “quiet” moves. In this way, short-term “material jumps” of 1-2 moves during exchanges were filtered out.

Then, using the “1-3-3-5-9” scale we already know, the material balance of the position was calculated, and for each of its values ​​(from -24 to 24) the number of points scored by White was accumulated. The obtained statistics are presented in the following graph:

Along the x-axis is the material balance of the position ΔM from White's point of view, in pawns. It is calculated as the difference between the total value of all white pieces and pawns and the same value for black ones. Along the y-axis is the selective mathematical expectation of the game result (0 - black victory, 0.5 - draw, 1 - white victory). We see that the experimental data are very well described logistic curve:

A simple visual selection allows you to determine the curve parameter: α=0.7, its dimension is inverse pawns.
For comparison, the graph shows two more logistic curves with different parameter values α .

What does this mean in practice? Let us see a randomly chosen position in which White has an advantage of 2 pawns ( ΔM = 2). With a probability close to 80%, we can say: the game will end in victory for White. Likewise, if White lacks a bishop or knight ( ΔM = -3), their chances of not losing are only about 12%. Positions with material equality ( ΔM = 0), as one might expect, most often end in a draw.

Formulation of the problem

We are now ready to formulate the estimation function optimization problem in terms of logistic regression.
Let us be given a set of vectors of the following form:

Where Δ i , i = P...Q- the difference in the number of white and black pieces of the type i(from pawn to queen, we don’t count the king). These vectors represent material relationships found in batches (one batch usually corresponds to several vectors).

Let also be given the vector y j, whose components take values ​​0, 1 and 2. These values ​​correspond to the outcomes of the games: 0 - black victory, 1 - draw, 2 - white victory.

Need to find a vector θ figure values:

Minimizing the cost function for logistic regression:

,
Where
- logistic function for the vector argument.

To prevent “overfitting” and instability effects in the found solution, you can add a regularization parameter to the cost function, which prevents the coefficients in the vector from taking too large values:

The value of the coefficient for the regularization parameter is chosen to be small; in this case, the value was used λ=10 -6.

To solve the minimization problem, we apply the simplest gradient descent method with a constant step:

Where are the gradient components of the function Jreg have the form:

Since we are looking for a symmetric solution, which, given material equality, gives the probability of the outcome of the game ½, the zero coefficient of the vector θ We always assume it is equal to zero, and for the gradient we need only the second of these expressions.

We will not consider the derivation of the above formulas here. I highly recommend the already mentioned machine learning course on Coursera to anyone interested in their rationale.

Program and results

Since the first part of the task - parsing PGN files and selecting a set of features for each position - was already practically implemented in the chess engine code, it was decided to also write the remaining part in C++. The source code of the program and test sets of batches in PGN files are available on github. The program can be compiled and run under Windows (MSVC) or Linux (gcc).

Possibility to use specialized tools like Octave, MATLAB, R, etc. in the future. is also provided - during operation the program generates an intermediate text file with sets of characteristics and game outcomes, which can easily be imported into these environments.

The file contains a text representation of a set of vectors x j- dimension matrices mx(n+1), the first 5 columns of which contain the components of the material balance (from pawn to queen), and the 6th column contains the result of the game.

Let's look at a simple example. Below is the PGN record of one of the test batches.

1. d4 d5 2. c4 e6 3. e3 c6 4. Nf3 Nd7 5. Nbd2 Nh6 6. e4 Bb4 7. a3 Ba5 8. cxd5 exd5 9. exd5 cxd5 10. Qe2+ Kf8 11. Qb5 Nf6 12. Bd3 Qe7+ 13. Kd1 Bb6 14. Re1 Bd7 15. Qb3 Be6 16. Re2 Qc7 17. Qb4+ Kg8 18. Nb3 Bf5 19. Bb1 Bxb1 20. Rxb1 Nf5 21. Bd2 a5 22. Qa4 h6 23. Rc1 Qb8 24. Bxa5 Qf4 25. Qb4 Bx a5 26. Nxa5 Kh7 27. Nxb7 Rab8 28. a4 Ne4 29. h3 Rhc8 30. Ra1 Rc7 31. Qa3 Rcxb7 32. g3 Qc7 33. Rc1 Qa5 34. Rxe4 dxe4 35. Rc5 Qa6 36. Nd2 Nxd4 37. Rc4 Nb3 3 8. Nxb3 Qxc4 39. Nd2 Rd8 40. Qc3 Qf1+ 41. Kc2 Qe2 42. f4 e3 43. b4 Rc7 44. Kb3 Qd1+ 45. Ka2 Rxc3 46. Nb1 Qxa4+ 47. Na3 Rc2+ 48. Ka1 Rd1# 0-1
The corresponding fragment of the intermediate file looks like:

0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 2 -1 0 0 0 0 2 0 0 -1 0 0 1 0 0 -1 0 0 1 1 0 -2 0 0
In the 6th column, 0 is everywhere - this is the result of the game, a victory for Black. The remaining columns show the balance of the number of pieces on the board. The first line contains complete material equality, all components are equal to 0. The second line is White’s extra pawn, this is the position after the 24th move. Please note that the previous exchanges are not reflected in any way; they happened too quickly. After the 27th move, White already has 2 extra pawns - this is line 3. Etc. Before Black's final attack, White has a pawn and a knight for two rooks:

Like the exchanges in the opening, the final moves in the game did not affect the contents of the file. They were eliminated by the “tactics filter” because they were a series of captures, checks and evasions.

The same records are created for all analyzed games, on average 5-10 lines per game. After parsing the PGN database with batches, this file enters the input of the second part of the program, which is engaged in the actual solution of the minimization problem.

As a starting point for gradient descent, you can, for example, take a vector with the values ​​of the weights of the shapes from the textbook. But it’s more interesting not to give the algorithm any hints, and to start from scratch. It turns out that our cost function is quite “good” - the trajectory quickly, within several thousand steps, reaches the global minimum. How the values ​​of the pieces change in this case is shown in the following graph (at each step, normalization was performed by the weight of the pawn = 100):

Cost Function Convergence Graph


Program text output

C:\CHESS>pgnlearn.exe OpenRating.pgn Reading file: OpenRating.pgn Games: 2997 Created file: OpenRating.mat Loading dataset... [ 20196 x 5 ] Solving (gradient method)... Iter 0: [ 0 0 0 0 0 ] -> 0.693147 Iter 1000: [ 0.703733 1.89849 2.31532 3.16993 6.9148 ] -> 0.470379 Iter 2000: [ 0.735853 2.08733 2.51039 3.47418 7. 7387 ] -> 0.469398 Iter 3000: [ 0.74429 2.13676 2.56152 3.55386 7.95879 ] -> 0.46933 Iter 4000: [ 0.746738 2.15108 2.57635 3.57697 8.02296 ] -> 0.469324 Iter 5000: [ 0.747467 2.15535 2.58077 3.58385 8.0421 ] -> 0.469324 Iter 6000: [ 0.747685 2.15663 2.58209 3.58591 8.04785 ] -> 0.469324 Iter 7000: [ 0.747751 2.15702 2.58249 3.58653 8.04958 ] -> 0.469324 Iter 8000 : [ 0.747771 2.15713 2.58261 3.58672 8.0501 ] -> 0.469324 Iter 9000: [ 0.747777 2.15717 2.58265 3.58678 8.05026 ] -> 0.469324 Iter 1000 0: [ 0.747779 2.15718 2.58266 3.58679 8.0503 ] -> 0.469324 PIECE VALUES: Pawn: 100 Knight: 288.478 Bishop: 345.377 Rook : 479.66 Queen: 1076.56 Press ENTER to finish


After normalization and rounding we get the following set of values:
Let's check whether the “Capablanca rules” are followed?
Ratio Numerical values Performed?
B>N 345 > 288 Yes
B>3P 345 > 3 * 100 Yes
N>3P 288 < 3 * 100 No
B+N=R+1.5P 345 + 288 ~= 480 + 1.5 * 100 yes (with error< 0.5%)
Q + P = 2R 1077 + 100 > 2 * 480 No
The result is quite encouraging. Without knowing anything about the events actually happening on the board, and considering only the outcomes of the games and the material taken from the board, our algorithm was able to derive the values ​​of the pieces that were quite close to their traditional values.

Can the obtained values ​​be used to enhance the program's performance? Unfortunately, at this stage the answer is no. Test blitz matches show that the strength of GreKo's game practically did not change from using the found parameters, and in some cases even decreased. Why did it happen? One obvious reason is the already mentioned close connection between search and position evaluation. The search engine contains a number of heuristics for cutting off unpromising branches, and the criteria for these cuts (threshold values) are closely tied to the static assessment. By changing the values ​​of the figures, we sharply shift the scale of values ​​- the shape of the search tree changes, and a new balancing of constants is required for all heuristics. This is quite a time-consuming task.

Experiment with batches of people

Let's try to expand our experiment by considering games not only of computers, but also of people. As a data set for training, we will take the games of two outstanding modern grandmasters - world champion Magnus Carlsen and ex-champion Anand Viswanathan, as well as the representative of romantic chess of the 19th century, Adolf Andersen.


Anand and Carlsen vying for world crown

The table below shows the results of solving the regression problem for the games of these chess players.
It is easy to notice that the “human” values ​​of the values ​​of the figures turned out to be not at all the same as what beginners are taught in textbooks. In the case of Carlsen and Anand, the smaller scale of the scale is striking - the queen is worth a little more than 7.5 pawns, and the entire range for other pieces has shrunk accordingly. The bishop is still slightly more expensive than the knight, but both fall short of the traditional three pawns. Two rooks turn out to be weaker than the queen, etc.

It must be said that a similar picture is observed not only for Vishy and Magnus, but also for the majority of grandmasters whose games were tested. Moreover, no dependence on style was found. The values ​​are shifted from the classical ones in the same direction both for positional masters like Mikhail Botvinnik and Anatoly Karpov, and for attacking chess players - Mikhail Tal, Judit Polgar...

One of the few exceptions was Adolf Andersen, the best European player of the mid-19th century, author of the famous “evergreen game”. For him, the value values ​​of the figures turned out to be very close to those used by computer programs. A wide variety of fantastic hypotheses arise, such as the secret cheating of the German maestro through a portal in time... (Joke, of course. Adolf Andersen was an extremely decent person, and would never allow himself to do this.)


Adolf Andersen (1818-1879),
human-computer

Why is there such an effect with a compression of the price range of figures? Of course, we should not forget about the extreme limitations of our model - taking into account additional positional factors could make significant adjustments. But perhaps it’s a matter of a person’s poor technique for realizing a material advantage - relative to modern chess programs, of course. Simply put, it is difficult for a person to play the queen without mistakes, because he has too many options. I remember the textbook anecdote about Lasker (in other versions - Capablanca / Alekhine / Tal), allegedly playing with a handicap with a random fellow traveler on the train. The climax phrase was: “The queen is just in the way!”

Conclusion

We looked at one aspect of the evaluation function of chess programs - the cost of the material. We were convinced that this part of the static assessment in the Shannon model has a completely “physical” meaning - it is smoothly (through the logistic function) connected with the probability of the outcome of the game. Then we looked at several common combinations of piece weights and assessed the order of their influence on the strength of the program's play.

Using the regression apparatus on the games of various chess players, both live and computer, we determined the optimal values ​​of the pieces under the assumption of a purely material evaluation function. We discovered an interesting effect of the lower cost of material for people compared to machines, and “suspected” one of the chess classics of cheating. We tried to apply the found values ​​in a real engine and... did not achieve much success.

Where to go next? To more accurately estimate the position, you can add new chess knowledge to the model - that is, increase the dimension of the vectors x And θ . Even remaining in the area of ​​only material criteria (without taking into account the fields occupied by the pieces on the board), one can add a whole series of relevant features: two bishops, a pair of queen and knight, a pair of rook and bishop, a different color, the last pawn in the endgame... Chess players are well aware , how the value of pieces can depend on their combination or the stage of the game. In chess programs, the corresponding weights (bonuses or penalties) can reach tenths of a pawn or more.

One possible way (along with increasing the sample size) is to use games played by a previous version of the same program for training. In this case, there is hope for greater consistency of some assessment features with others. It is also possible to use as a cost function not the success of predicting the outcome of the game (which may end several dozen moves after the position in question), but the correlation of the static assessment with the dynamic one - i.e. with the result of an alpha-beta search to a certain depth.

However, as noted above, the results obtained may not be suitable for directly enhancing the game of the program. This often happens: after training on a series of tests, the program begins to improve solve tests(in our case - to predict the results of games), but not better play! Currently, intensive testing exclusively in practical play has become mainstream in chess programming. New versions of top engines are tested on tens and hundreds of thousands of batches with ultra-short time controls before release...

In any case, I plan to conduct a series of more experiments on statistical analysis of chess games. If this topic is of interest to Habr’s audience, if any non-trivial results are obtained, the article may be continued.

During the research, not a single chess piece was harmed.

Bibliography

Adelson-Velsky, G.M.; Arlazarov, V.L.; Bitman, A.R. etc. - The machine plays chess. M.: Nauka, 1983
A book by the authors of the Soviet program “Kaissa”, which describes in detail both the general algorithmic foundations of chess programs and the specific details of the implementation of the evaluation function and search for “Kaissa”.

Kornilov E. - Programming chess and other logic games. St. Petersburg: BHV-Petersburg, 2005
A more modern and “practical” book, it contains a large number of code examples.

Feng-hsiung Hsu - Behind Deep Blue. Princeton University Press, 2002
A book by one of the creators of the Deep Blue chess machine, telling in detail about the history of its creation and internal structure. The appendix contains the texts of all chess games played by Deep Blue in official competitions.

Links

Chessprogramming Wiki - an extensive collection of materials on all theoretical and practical aspects of chess programming.

Machine Learning in Games - a site dedicated to machine learning in games. Contains a large number of scientific articles on research in the field of chess, checkers, Go, reversi, backgammon, etc.

Kaissa - page dedicated to “Kaissa”. The coefficients of its evaluation function are presented in detail.

Stockfish is the strongest open source program available today.

A comparison of Rybka 1.0 beta and Fruit 2.1
A detailed comparison of the internal structure of two popular chess programs.

GreKo is the chess program of the author of the article.
It was used as one of the sources of test computer batches. Also, based on its move generator and PGN notation parser, a utility for analyzing experimental data was developed.

pgnlearn - utility code and example batch files on github.

Tags: Add tags

Read by Andrew Ng on Coursera. After getting acquainted with the methods discussed in the lectures, I wanted to apply them to some real problem. I didn’t have to search for a topic for a long time - optimization of my own chess engine simply suggested itself as a subject area.

Introduction: about chess programs

We will not delve into the architecture of chess programs in detail - this could be the topic of a separate publication or even a series of them. Let's consider only the most basic principles. The main components of almost any non-protein chess player are search And position assessment.

The search is an enumeration of options, that is, iterative deepening through the game tree. The evaluation function maps a set of positional features onto a numerical scale and serves as an objective function for finding the best move. It is applied to the leaves of the tree, and is gradually "returned" to the original position (the root) using the alpha-beta procedure or its variations.

Strictly speaking, real the score can only take three values: win, loss or draw - 1, 0 or ½. According to Zermelo's theorem, for any given position it is uniquely determined. In practice, due to the combinatorial explosion, not a single computer is able to calculate options down to the leaves of the full game tree (exhaustive analysis in endgame databases is a separate case; 32-piece tables will not appear in the foreseeable future... and in the foreseeable future, most likely, Same). Therefore, programs work in the so-called Shannon models- use a truncated game tree and an approximate estimate based on various heuristics.

Search and evaluation do not exist independently of each other, they must be well balanced. Modern search algorithms are no longer a “dumb” search of options; they include numerous special rules, including those related to position evaluation.

The first such search improvements appeared at the dawn of chess programming, in the 60s of the 20th century. We can mention, for example, technology forced version (FV)- extension of individual search branches until the position “calms down” (checks and mutual captures of pieces end). Extensions significantly increase the tactical vigilance of the computer, and also lead to the fact that the search tree becomes very heterogeneous - the length of individual branches can be several times greater than the length of neighboring, less promising ones. Other search improvements, on the other hand, are cutting off or search abbreviations- and here, among other things, the same static assessment can serve as a criterion for discarding bad options.

Parameterization and improvement of search using machine learning methods is a separate interesting topic, but for now we will leave it aside. Let us deal only with the evaluation function for now.

How does a computer evaluate a position?


A static estimate is a linear combination of various position attributes taken with certain weighting coefficients. What are these signs? First of all, the number of pieces and pawns on both sides. The next important sign is the position of these figures, centralization, occupation of open lines and diagonals by long-range figures. Experience shows that taking into account only these two factors - the amount of material and the relative value of the fields (fixed in the form of tables for each type of figure) - in the presence of a high-quality search can already ensure the strength of the game in the range of up to 2000-2200 Elo points. This is the level of a good first class or candidate master.

Further refinement of the assessment may include more and more subtle signs of a chess position: the presence and advancement of passed pawns, the proximity of pieces to the position of the enemy king, his pawn cover, etc. The legendary "Kaissa", the first world champion among programs (1974) had an assessment a function of several dozen features. All of them are described in detail in the book “The Machine Plays Chess,” a bibliographic link to which is provided at the end of the article.


One of the most sophisticated evaluation functions was that of the Deep Blue machine, which became famous for its matches with Kasparov in 1996-97. (For a detailed history of these matches, see a recent series of articles on Geektimes.)

It is widely believed that Deep Blue's strength was based solely on its colossal speed of iteration. 200 million positions per second, full (without cutting) search for 12 half-moves - chess programs on modern hardware are just approaching such parameters. However, it wasn't just about speed. In terms of the amount of “chess knowledge” in the evaluation function, this machine was also far superior to everyone else. The Deep Blue evaluation was implemented in hardware and included up to 8000 different features. Strong grandmasters were brought in to adjust its coefficients (it is reliably known that they worked with Joel Benjamin; David Bronstein played test games with different versions of the machine).

Without having such resources as the creators of Deep Blue, we will limit the task. Of all the characteristics of a position taken into account to calculate the score, let’s take the most significant one - the ratio of material on the board.

Cost of figures: simplest models

If you take any chess book for beginners, immediately after the chapter explaining the chess moves there is usually a table of the comparative values ​​of the pieces, something like this:
The king is sometimes assigned a final value that is obviously greater than the sum of all the material on the board - for example, 200 units. In this study we will leave His Majesty alone and will not consider kings at all. Why? The answer is simple: they are always present on the board, so their material assessments are mutually subtracted and do not affect the overall balance of power.

The figures' values ​​shown should only be considered as some basic guidelines. In reality, pieces can become “more expensive” and “cheaper” depending on the situation on the board, as well as on the stage of the game. Combinations of two or three pieces - one's own and the enemy's - are usually considered as a first-order amendment.

This is how the third world champion assessed various combinations of material in his classic “Textbook of Chess”:


From the point of view of general theory, the bishop and knight should be considered equally valuable, although, in my opinion, the bishop in most cases turns out to be a stronger piece. Meanwhile, it is considered completely established that two bishops are almost always stronger than two knights.

A bishop in a game against pawns is stronger than a knight, and together with pawns it also turns out to be stronger against a rook than a knight. The bishop and rook are also stronger than the knight and rook, but the queen and knight can be stronger than the queen and bishop. A bishop is often worth more than three pawns, but the same can rarely be said about a knight; he may even be weaker than three pawns.

A rook is equal in strength to a knight and two pawns or a bishop and two pawns, but, as stated above, a bishop is stronger than a knight in a fight against a rook. Two rooks are slightly stronger than the queen. They are slightly weaker than two knights and a bishop and even weaker than two bishops and a knight. The strength of the knights decreases as pieces are exchanged on the board, while the strength of the rook, on the contrary, increases.

Finally, as a rule, three minor pieces are stronger than the queen.

It turns out that most of these rules can be satisfied by remaining within the linear model and simply slightly shifting the values ​​of the figures from their “school” values. For example, one of the articles provides the following boundary conditions:

B > N > 3P B + N = R + 1.5P Q + P = 2R
And the values ​​that satisfy them:

P = 100 N = 320 B = 330 R = 500 Q = 900 K = 20000


The names of the variables correspond to the designations of the pieces in English notation: P - pawn, N - knight, B - bishop, R - rook, Q - queen, K - king. The values ​​here and below are indicated in hundredths of a pawn.

In fact, the given set of values ​​is not the only solution. Moreover, even non-compliance with some of the “inequalities to them. Capablanca" will not lead to a sharp drop in the strength of the program's playing, but will only affect its stylistic features.

As an experiment, I conducted a small match-tournament of four versions of my GreKo engine with different weights of pieces against three other programs - each version played 3 matches of 200 games with ultra-short time control (1 second + 0.1 sec per move). The results are shown in the table:

Version Pawn Horse Elephant Rook Queen vs. Fruit 2.1 vs. Crafty 23.4 vs. Delfi 5.4 Rating
Greko 12.5 100 400 400 600 1200 61.0 76.0 71.0 2567
GreKo A 100 300 300 500 900 55.0 69.0 73.0 2552
GreKo B 100 320 330 500 900 57.0 71.0 64.0 2548
GreKo C 100 325 325 550 1100 72.5 74.5 69.0 2575
We see that some variations in the weights of the pieces lead to fluctuations in the strength of the game in the range of 20-30 Elo points. Moreover, one of the test versions showed even better results than the main version of the program. However, it is premature to say unequivocally about the strengthening of the game with such a small number of games - the confidence interval for calculating the rating is a comparable value of several tens of Elo points.

The “classical” values ​​of chess material were obtained intuitively, through the chess players’ understanding of their practical experience. Attempts were also made to put some kind of mathematical basis under these values ​​- for example, based on the mobility of figures, the number of fields that they can keep under control. We will try to approach the issue experimentally - based on the analysis of a large number of chess games. To calculate the values ​​of the figures we will not need an approximate assessment of positions from these games is only their results, as the most objective measure of success in chess.

Material superiority and logistic curve

For statistical analysis, a PGN file was taken containing almost 3000 blitz chess games between 32 different chess engines, ranging from 1800 to 3000 Elo points. Using a specially written utility, a list of material relationships that appeared on the board was compiled for each game. Each ratio of material did not enter the statistics immediately after capturing a piece or promoting a pawn - first there had to be reciprocal captures or several “quiet” moves. In this way, short-term “material jumps” of 1-2 moves during exchanges were filtered out.

Then, using the “1-3-3-5-9” scale we already know, the material balance of the position was calculated, and for each of its values ​​(from -24 to 24) the number of points scored by White was accumulated. The obtained statistics are presented in the following graph:

Along the x-axis is the material balance of the position ΔM from White's point of view, in pawns. It is calculated as the difference between the total value of all white pieces and pawns and the same value for black ones. Along the y-axis is the selective mathematical expectation of the game result (0 - black victory, 0.5 - draw, 1 - white victory). We see that the experimental data are very well described logistic curve:

A simple visual selection allows you to determine the curve parameter: α=0.7, its dimension is inverse pawns.
For comparison, the graph shows two more logistic curves with different parameter values α .

What does this mean in practice? Let us see a randomly chosen position in which White has an advantage of 2 pawns ( ΔM = 2). With a probability close to 80%, we can say: the game will end in victory for White. Likewise, if White lacks a bishop or knight ( ΔM = -3), their chances of not losing are only about 12%. Positions with material equality ( ΔM = 0), as one might expect, most often end in a draw.

Formulation of the problem

We are now ready to formulate the estimation function optimization problem in terms of logistic regression.
Let us be given a set of vectors of the following form:

Where Δ i , i = P...Q- the difference in the number of white and black pieces of the type i(from pawn to queen, we don’t count the king). These vectors represent material relationships found in batches (one batch usually corresponds to several vectors).

Let also be given the vector y j, whose components take values ​​0, 1 and 2. These values ​​correspond to the outcomes of the games: 0 - black victory, 1 - draw, 2 - white victory.

Need to find a vector θ figure values:

Minimizing the cost function for logistic regression:

,
Where
- logistic function for the vector argument.

To prevent “overfitting” and instability effects in the found solution, you can add a regularization parameter to the cost function, which prevents the coefficients in the vector from taking too large values:

The value of the coefficient for the regularization parameter is chosen to be small; in this case, the value was used λ=10 -6.

To solve the minimization problem, we apply the simplest gradient descent method with a constant step:

Where are the gradient components of the function Jreg have the form:

Since we are looking for a symmetric solution, which, given material equality, gives the probability of the outcome of the game ½, the zero coefficient of the vector θ We always assume it is equal to zero, and for the gradient we need only the second of these expressions.

We will not consider the derivation of the above formulas here. I highly recommend the already mentioned machine learning course on Coursera to anyone interested in their rationale.

Program and results

Since the first part of the task - parsing PGN files and selecting a set of features for each position - was already practically implemented in the chess engine code, it was decided to also write the remaining part in C++. The source code of the program and test sets of batches in PGN files are available on github. The program can be compiled and run under Windows (MSVC) or Linux (gcc).

Possibility to use specialized tools like Octave, MATLAB, R, etc. in the future. is also provided - during operation the program generates an intermediate text file with sets of characteristics and game outcomes, which can easily be imported into these environments.

The file contains a text representation of a set of vectors x j- dimension matrices mx(n+1), the first 5 columns of which contain the components of the material balance (from pawn to queen), and the 6th column contains the result of the game.

Let's look at a simple example. Below is the PGN record of one of the test batches.

1. d4 d5 2. c4 e6 3. e3 c6 4. Nf3 Nd7 5. Nbd2 Nh6 6. e4 Bb4 7. a3 Ba5 8. cxd5 exd5 9. exd5 cxd5 10. Qe2+ Kf8 11. Qb5 Nf6 12. Bd3 Qe7+ 13. Kd1 Bb6 14. Re1 Bd7 15. Qb3 Be6 16. Re2 Qc7 17. Qb4+ Kg8 18. Nb3 Bf5 19. Bb1 Bxb1 20. Rxb1 Nf5 21. Bd2 a5 22. Qa4 h6 23. Rc1 Qb8 24. Bxa5 Qf4 25. Qb4 Bx a5 26. Nxa5 Kh7 27. Nxb7 Rab8 28. a4 Ne4 29. h3 Rhc8 30. Ra1 Rc7 31. Qa3 Rcxb7 32. g3 Qc7 33. Rc1 Qa5 34. Rxe4 dxe4 35. Rc5 Qa6 36. Nd2 Nxd4 37. Rc4 Nb3 3 8. Nxb3 Qxc4 39. Nd2 Rd8 40. Qc3 Qf1+ 41. Kc2 Qe2 42. f4 e3 43. b4 Rc7 44. Kb3 Qd1+ 45. Ka2 Rxc3 46. Nb1 Qxa4+ 47. Na3 Rc2+ 48. Ka1 Rd1# 0-1
The corresponding fragment of the intermediate file looks like:

0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 2 -1 0 0 0 0 2 0 0 -1 0 0 1 0 0 -1 0 0 1 1 0 -2 0 0
In the 6th column, 0 is everywhere - this is the result of the game, a victory for Black. The remaining columns show the balance of the number of pieces on the board. The first line contains complete material equality, all components are equal to 0. The second line is White’s extra pawn, this is the position after the 24th move. Please note that the previous exchanges are not reflected in any way; they happened too quickly. After the 27th move, White already has 2 extra pawns - this is line 3. Etc. Before Black's final attack, White has a pawn and a knight for two rooks:

Like the exchanges in the opening, the final moves in the game did not affect the contents of the file. They were eliminated by the “tactics filter” because they were a series of captures, checks and evasions.

The same records are created for all analyzed games, on average 5-10 lines per game. After parsing the PGN database with batches, this file enters the input of the second part of the program, which is engaged in the actual solution of the minimization problem.

As a starting point for gradient descent, you can, for example, take a vector with the values ​​of the weights of the shapes from the textbook. But it’s more interesting not to give the algorithm any hints, and to start from scratch. It turns out that our cost function is quite “good” - the trajectory quickly, within several thousand steps, reaches the global minimum. How the values ​​of the pieces change in this case is shown in the following graph (at each step, normalization was performed by the weight of the pawn = 100):

Cost Function Convergence Graph


Program text output

C:\CHESS>pgnlearn.exe OpenRating.pgn Reading file: OpenRating.pgn Games: 2997 Created file: OpenRating.mat Loading dataset... [ 20196 x 5 ] Solving (gradient method)... Iter 0: [ 0 0 0 0 0 ] -> 0.693147 Iter 1000: [ 0.703733 1.89849 2.31532 3.16993 6.9148 ] -> 0.470379 Iter 2000: [ 0.735853 2.08733 2.51039 3.47418 7. 7387 ] -> 0.469398 Iter 3000: [ 0.74429 2.13676 2.56152 3.55386 7.95879 ] -> 0.46933 Iter 4000: [ 0.746738 2.15108 2.57635 3.57697 8.02296 ] -> 0.469324 Iter 5000: [ 0.747467 2.15535 2.58077 3.58385 8.0421 ] -> 0.469324 Iter 6000: [ 0.747685 2.15663 2.58209 3.58591 8.04785 ] -> 0.469324 Iter 7000: [ 0.747751 2.15702 2.58249 3.58653 8.04958 ] -> 0.469324 Iter 8000 : [ 0.747771 2.15713 2.58261 3.58672 8.0501 ] -> 0.469324 Iter 9000: [ 0.747777 2.15717 2.58265 3.58678 8.05026 ] -> 0.469324 Iter 1000 0: [ 0.747779 2.15718 2.58266 3.58679 8.0503 ] -> 0.469324 PIECE VALUES: Pawn: 100 Knight: 288.478 Bishop: 345.377 Rook : 479.66 Queen: 1076.56 Press ENTER to finish


After normalization and rounding we get the following set of values:
Let's check whether the “Capablanca rules” are followed?
Ratio Numerical values Performed?
B>N 345 > 288 Yes
B>3P 345 > 3 * 100 Yes
N>3P 288 < 3 * 100 No
B+N=R+1.5P 345 + 288 ~= 480 + 1.5 * 100 yes (with error< 0.5%)
Q + P = 2R 1077 + 100 > 2 * 480 No
The result is quite encouraging. Without knowing anything about the events actually happening on the board, and considering only the outcomes of the games and the material taken from the board, our algorithm was able to derive the values ​​of the pieces that were quite close to their traditional values.

Can the obtained values ​​be used to enhance the program's performance? Unfortunately, at this stage the answer is no. Test blitz matches show that the strength of GreKo's game practically did not change from using the found parameters, and in some cases even decreased. Why did it happen? One obvious reason is the already mentioned close connection between search and position evaluation. The search engine contains a number of heuristics for cutting off unpromising branches, and the criteria for these cuts (threshold values) are closely tied to the static assessment. By changing the values ​​of the figures, we sharply shift the scale of values ​​- the shape of the search tree changes, and a new balancing of constants is required for all heuristics. This is quite a time-consuming task.

Experiment with batches of people

Let's try to expand our experiment by considering games not only of computers, but also of people. As a data set for training, we will take the games of two outstanding modern grandmasters - world champion Magnus Carlsen and ex-champion Anand Viswanathan, as well as the representative of romantic chess of the 19th century, Adolf Andersen.


Anand and Carlsen vying for world crown

The table below shows the results of solving the regression problem for the games of these chess players.
It is easy to notice that the “human” values ​​of the values ​​of the figures turned out to be not at all the same as what beginners are taught in textbooks. In the case of Carlsen and Anand, the smaller scale of the scale is striking - the queen is worth a little more than 7.5 pawns, and the entire range for other pieces has shrunk accordingly. The bishop is still slightly more expensive than the knight, but both fall short of the traditional three pawns. Two rooks turn out to be weaker than the queen, etc.

It must be said that a similar picture is observed not only for Vishy and Magnus, but also for the majority of grandmasters whose games were tested. Moreover, no dependence on style was found. The values ​​are shifted from the classical ones in the same direction both for positional masters like Mikhail Botvinnik and Anatoly Karpov, and for attacking chess players - Mikhail Tal, Judit Polgar...

One of the few exceptions was Adolf Andersen, the best European player of the mid-19th century, author of the famous “evergreen game”. For him, the value values ​​of the figures turned out to be very close to those used by computer programs. A wide variety of fantastic hypotheses arise, such as the secret cheating of the German maestro through a portal in time... (Joke, of course. Adolf Andersen was an extremely decent person, and would never allow himself to do this.)


Adolf Andersen (1818-1879),
human-computer

Why is there such an effect with a compression of the price range of figures? Of course, we should not forget about the extreme limitations of our model - taking into account additional positional factors could make significant adjustments. But perhaps it’s a matter of a person’s poor technique for realizing a material advantage - relative to modern chess programs, of course. Simply put, it is difficult for a person to play the queen without mistakes, because he has too many options. I remember the textbook anecdote about Lasker (in other versions - Capablanca / Alekhine / Tal), allegedly playing with a handicap with a random fellow traveler on the train. The climax phrase was: “The queen is just in the way!”

Conclusion

We looked at one aspect of the evaluation function of chess programs - the cost of the material. We were convinced that this part of the static assessment in the Shannon model has a completely “physical” meaning - it is smoothly (through the logistic function) connected with the probability of the outcome of the game. Then we looked at several common combinations of piece weights and assessed the order of their influence on the strength of the program's play.

Using the regression apparatus on the games of various chess players, both live and computer, we determined the optimal values ​​of the pieces under the assumption of a purely material evaluation function. We discovered an interesting effect of the lower cost of material for people compared to machines, and “suspected” one of the chess classics of cheating. We tried to apply the found values ​​in a real engine and... did not achieve much success.

Where to go next? To more accurately estimate the position, you can add new chess knowledge to the model - that is, increase the dimension of the vectors x And θ . Even remaining in the area of ​​only material criteria (without taking into account the fields occupied by the pieces on the board), one can add a whole series of relevant features: two bishops, a pair of queen and knight, a pair of rook and bishop, a different color, the last pawn in the endgame... Chess players are well aware , how the value of pieces can depend on their combination or the stage of the game. In chess programs, the corresponding weights (bonuses or penalties) can reach tenths of a pawn or more.

One possible way (along with increasing the sample size) is to use games played by a previous version of the same program for training. In this case, there is hope for greater consistency of some assessment features with others. It is also possible to use as a cost function not the success of predicting the outcome of the game (which may end several dozen moves after the position in question), but the correlation of the static assessment with the dynamic one - i.e. with the result of an alpha-beta search to a certain depth.

However, as noted above, the results obtained may not be suitable for directly enhancing the game of the program. This often happens: after training on a series of tests, the program begins to improve solve tests(in our case - to predict the results of games), but not better play! Currently, intensive testing exclusively in practical play has become mainstream in chess programming. New versions of top engines are tested on tens and hundreds of thousands of batches with ultra-short time controls before release...

In any case, I plan to conduct a series of more experiments on statistical analysis of chess games. If this topic is of interest to Habr’s audience, if any non-trivial results are obtained, the article may be continued.

During the research, not a single chess piece was harmed.

Bibliography

Adelson-Velsky, G.M.; Arlazarov, V.L.; Bitman, A.R. etc. - The machine plays chess. M.: Nauka, 1983
A book by the authors of the Soviet program “Kaissa”, which describes in detail both the general algorithmic foundations of chess programs and the specific details of the implementation of the evaluation function and search for “Kaissa”.

Kornilov E. - Programming chess and other logic games. St. Petersburg: BHV-Petersburg, 2005
A more modern and “practical” book, it contains a large number of code examples.

Feng-hsiung Hsu - Behind Deep Blue. Princeton University Press, 2002
A book by one of the creators of the Deep Blue chess machine, telling in detail about the history of its creation and internal structure. The appendix contains the texts of all chess games played by Deep Blue in official competitions.

Links

Chessprogramming Wiki - an extensive collection of materials on all theoretical and practical aspects of chess programming.

Machine Learning in Games - a site dedicated to machine learning in games. Contains a large number of scientific articles on research in the field of chess, checkers, Go, reversi, backgammon, etc.

Kaissa - page dedicated to “Kaissa”. The coefficients of its evaluation function are presented in detail.

Stockfish is the strongest open source program available today.

A comparison of Rybka 1.0 beta and Fruit 2.1
A detailed comparison of the internal structure of two popular chess programs.

GreKo is the chess program of the author of the article.
It was used as one of the sources of test computer batches. Also, based on its move generator and PGN notation parser, a utility for analyzing experimental data was developed.

pgnlearn - utility code and example batch files on github.

Tags:

  • chess
  • regression analysis
  • machine learning
Add tags

Hello Hello. Friends, do you know what the pieces in chess are called? The fact is that my friends and I call the same figures completely differently, and sometimes we get confused about the names. That’s why I’m writing this article, from which you will learn the names of chess pieces in different countries, and why they are called that and what size they are. Let's look at the names of the figures.

I don't consider myself a strong player, but I can still do something. Checkmate in four moves, for example. And it turns out that my friends and I play chess quite rarely, but for a long time: the game is not fast and is quite interesting. Chess appeared a long time ago, and in different countries they are called (called) differently. Since I like everything simple (remember “Everything ingenious is simple”), I like the names of chess pieces simple: queen, officer, rook...

But my friends prefer more modern names, which is why we have some misunderstanding - who is used to what, you know. But we will figure all this out right now.

Abroad

Have you ever wondered why modern chess looks the way it does? Their appearance was formed a long time ago, but under the influence of many factors. And somehow it happened that we adopted the appearance of chess, but gave our own names, although we are not above using foreign ones.

Let's start with small things - pawns. Both here and abroad, pawns are called pawns. There is nothing unusual here, but further on there is more.

Horse. What do you think foreigners call a horse? Do you think like us – a horse? But they didn’t guess: they have a knight. Well, it’s like a knight on a horse, you understand.


An officer. Everything here is generally interesting. I always wondered why the officer had such a cone-shaped appearance. The answer shocked me. Remember when I said that we adopted the appearance, although we gave our own names? So, our officer abroad (take a deep breath!) is a bishop, a priest. And now regarding the appearance: remember the Catholic priests with their cone-shaped headdresses (I wanted to say caps). This is how the officer looked like.

Do you think that's all? Nope. Elephant. This is also what an officer is called. Honestly, I don’t know why the elephant was called an elephant, but I suspect it was because of the ancient appearance of this figure. It was here that he became an officer, and abroad a bishop. Before that, there was an elephant. Like this: three names for one figure.

Rook. The strange thing is that the rook is an ancient Russian ship, although the figure looks like a tower. Again, someone else's appearance and our names. Among the Arabs it was the Roc, consonant with the English word “rook” - cliff or tower. Receive and sign. But foreigners call the rook a tour, which has become widespread among us. Tura is translated from various European languages ​​as a fortress tower. But since fortress towers cannot move, the tour is a siege tower. You understand, this is a heavy and slow design. Maybe that’s why they put her on the edge of the chessboard for a more difficult introduction to the “battlefield”? What do you think?

Queen. Translated from Persian - commander (ferz). In our country, the queen is usually called that, but I often hear (and I myself am an adherent of it - it’s simpler) another name. In my youth, it was not clear to me what a queen was: it was only later that I learned the true meaning. But “queen” is understandable to a child.

The king remained the king. That's all with him. Although you will be surprised at its name in the then Russian Empire. More on this below.


Our names

Just a century ago, our bishop was called an officer, the rook was called a tour (which I talked about), the queen was called a queen, and the king was called a general. Although I don’t know why the queen is lower in status than the general. A pawn and a knight were just a pawn and a knight.

Personally, it’s convenient for me like this: pawn, knight, officer, rook, queen, king. Agree, simple and clear, not like these queens, tours, bishops...

Figure sizes

Whatever the size of the figure, its height does not indicate its power. Thus, the highest figure is the king, although he can hardly be called a strong figure. Behind him comes the queen (queen) - just a little lower than him. Next comes the officer (bishop), although in terms of striking power and value it is inferior to the rook, which is lower than it.

The knight is on par with the rook, although they also cannot be called equal pieces: the knight is clearly weaker and less valuable. And the smallest is the pawn - this is understandable. This kind of illogicality can be seen in the sizes of chess.

There are 6 different types of pieces in chess: king, queen, rooks, bishops, knights and pawns. Chess is played by two people: one with black pieces, the other with white pieces. Each player has 16 pieces (combat units): one king and queen, two rooks, two knights and a bishop, and 8 pawns. Each figure moves differently...

For example: grandmaster Atalik Suat could not learn how a knight moves for about a year!!!

In our school, you or your child will learn to walk with all their figures in 1-2 hours!

This is what it looks like. Below and to the left of the chessboard are letters and numbers. They are called CHESS NOTATION.

Our trainers will talk about the author's developments for quickly and effectively learning notation.

Thanks to the notation, each field has its own name, for example: a3, e5, c4, h6, etc. The notation is used to make it possible to record each move made. First, the piece that makes the move is recorded, then the field from which it moves, and at the end - the field it resembled. For example: Ng1-f3, e2-e4, d2-d4, etc.

Each figure has its own designation.

Russian designations of pieces: king (KR), queen (F), rook (L), bishop (S), knight (K), pawns are not designated in any way. When they move, only squares are indicated (this can be seen above: e2-e4, d2-d4, etc.).

English designations for pieces: king (K), queen (Q), rook (R), bishop (B), knight (N).

Also, figures can be indicated by small drawings.

King

Many incompetent chess players call the king the most powerful piece. This is wrong.

During lectures with our trainers you will learn that

The King is the most IMPORTANT and MAIN figure, without which you cannot play according to the rules. All chess pieces have their value, but not the king. According to the rules, you can't beat him - that's why it's impossible to say how much he costs.

The diagram shows the possible moves of the king and its schematic representation.

The king can move to any adjacent square next to him in any direction (horizontally, diagonally or vertically), but only if this field is not attacked by enemy pieces or occupied by his own. The king hits in the same way as he moves, that is, he can eat any enemy piece standing nearby (if it is not protected).

In chess, there is a situation where the king can move to more squares. This is called castling.

Castling is a joint move of the king and the rook: the king moves two squares towards one of the rooks while simultaneously moving the rook to the square traversed by the king. Castling on the kingside is called short castling (denoted 0-0), castling on the queenside is called long castling (denoted 0-0-0). Castling is impossible in cases where the king stands on a square attacked by an opponent or at a time when it is already attacked. Also, according to the rules, you cannot castle if the king crosses the square attacked by the opponent.

The chessboard is divided into two flanks: queen (lines a, b, c, d) and king (lines e, f, g, h). The flanks get their names from the position of the pieces (the queen initially stands on d1, the king on e1).

Queen


The queen is the strongest piece. She moves both as a bishop and as a rook (we will look at the moves of the bishop and rook later).

The queen can move along diagonals, verticals and horizontals to any number of squares. It hits the same way.

The diagram shows the possible moves of the queen and its schematic representation.

At the beginning of the game, each opponent has one queen. The white queen is initially located on the d1 square (up to the “a” line - this is the queen’s side; this was described above), the black queen is on d8.

Our experienced coaches will tell you about the inappropriateness of introducing the queen into the game early.

The sooner the queen enters the game, the higher the danger that it will be attacked by the opponent’s weaker pieces. Trading the queen for any piece other than the enemy queen is unprofitable (after all, the queen is the strongest).

Also, upon enrolling in our school, you will learn:

A chess game is divided into three stages: debut - the beginning of the game (stage 1), middlegame (from German mittel - middle, spire - game) - middle of the game (stage 2), endgame (from German end - end, spire - game) - end of the game (stage 3).

In the initial position, White and Black each have 20 possible moves (4 moves with knights and 16 moves with pawns). You can verify this yourself (when you find out how all the pieces move).

Conclusion: there are 400 ways to play just the first move on both sides. Further more...

Rook

The rook is the second most powerful piece after the queen. Two rooks are approximately equal in strength to the queen, but may be stronger than it.

The rook moves along the verticals and horizontals to any number of squares. It hits too.

At the beginning of the game, each player has two rooks. They are located in the corners of the board (fields a1, h1, a8, h8).

Many people who are far from chess call the rook a tour.

From our trainers you will learn that this piece is called a rook. This way and only this way!

The rook can also make moves differently than described above. This move is castling (long and short) - see the "king" figure.

From our coaches you will learn what a rook endgame is and why it is the most difficult and most common...

Elephant

The bishop is noticeably weaker than the rook and significantly weaker than the queen, but is approximately equal in strength to the knight.

Our school coaches will talk about these situations

For example: it is possible to checkmate a lone king with two bishops, but not with two knights (with proper defense).

At the beginning of the game, each opponent has two bishops. They are located on squares c1, f1, c8, f8. Each side has a WHITE-SIDED and BLACK-SIDED bishop. It will be more clear after you learn how an elephant walks (see diagram).

The bishop moves along diagonals. Now it is clear that he can only control half of the board (32 out of 64 squares). One white bishop controls the white squares, the other controls the black squares. Black's bishops are no different.

The elephant beats in the same way as it walks. If an enemy piece comes across his way, he can take it away by standing on its square.

When you have two bishops, and your opponent has a bishop and a knight (or two knights), then it is generally accepted that there is approximate material balance on the board.

From our experienced trainers you will learn that having two bishops is almost always an advantage and learn how to use it

It is incorrect to call a bishop an OFFICER (just as a rook is a TOUR and a queen is a QUEEN).

An erudite, experienced and strong specialist will help you understand the correct names of chess pieces

Horse

The knight is considered one of the weakest pieces, although it also happens that it is better to have a knight than a bishop. In exceptional cases, a knight can be even stronger than a queen (!!), however, like any weaker piece, it can be better than a stronger one.

You will learn about such cases from our trainers (one of the more entertaining topics)

A chess knight is most similar to an ordinary knight (which cannot be said, for example, about a bishop and a rook).

At the beginning of the game, both sides have two knights. They are located on squares b1, g1, b8, g8. Learning to walk as a horse is difficult (this was mentioned at the beginning of the article), but...

Your child will be able to learn this in a short time and in an accessible, even playful form thanks to the experienced staff of the chess school

In the diagram the knight is on square e4. From here he can go to 8 different fields (and in eight directions).

Help: The knight, king and queen can move from one square in eight different directions. Bishop and rook - only in four.

Let's list where the knight can go from square e4: f2, d2, c3, c5, d6, f6, g5, g3.

The horse moves in a kind of zigzag - through an adjacent field (even an occupied one) vertically or horizontally, then moving away from its original position to one of the adjacent fields diagonally.

Simply put, the knight moves in the letter “G”: two fields vertically and one horizontally, or vice versa - two fields horizontally and one vertically.

The knight is very strong in closed positions (when the pawns of both sides are against each other), since it is the only piece that can jump over obstacles in its path.

The previous information about the horse is a drop in the bucket from what you need to know about him. You will learn about everything else by enrolling in our school.

Pawn

The pawn is the weakest combat unit, which is not even considered a piece. A pawn is just a pawn.

At the beginning of the game, the sides have 8 pawns. White is located on squares a2, b2, c2, d2, e2, f2, g2, h2. Black is located on squares a7, b7, c7, d7, e7, f7, g7, h7.

The pawn moves only one square vertically forward. True, from the initial field, she can go two fields forward at once.

Since the pawn is the weakest, all other pieces are valued at pawn equivalent. So,

At our school you will learn that:

- a knight and a bishop are worth approximately three pawns each;

- rook - approximately 5 pawns;

- queen - approximately 9 pawns.

There is no 100% specificity, since a lot depends on the specific position on the board, and therefore it is impossible to say for sure.

From the school's coaches you will learn about what positions we are talking about and how to determine the value of the pieces in them

According to their location, pawns are divided into rook, knight, bishop, and central (queen and king). The name of a pawn is determined by the name of the piece behind it.

A pawn captures differently than it moves (unlike other pieces):

And she hits diagonally (one field diagonally). (See diagram).

Since the pawn is already the weakest, it is endowed with another interesting ability: capturing en passant.

The diagram shows the “jamming on the pass” in dynamics. The black pawn moves from d7 to d5 and crosses the d6 square, which the white pawn attacked. In this case, the white pawn has the right to take the black one and move to the square it originally attacked, that is, d6.

You will learn more about this possibility of pawns from the lectures of our school, under the supervision of professionals in 1-1.5 hours

Another unique ability of the pawn is its promotion to any piece.

Let's imagine that in the position on the diagram, the white pawn stood on e7 (where the arrow begins) and moved to e8 (where the arrow ends). Consequently, the pawn was like the last rank (for White it is the eighth rank, for Black it is the first). In this case, the pawn has the right to transform into any piece (of course, except for the king - after all, he is the most important and each side can only have one). The diagram shows which pieces a pawn can choose for its promotion (queen, bishop, rook, knight). Almost always, a pawn is promoted to a queen, since the queen is the strongest piece (why promote to something weaker?)

Our school's trainers will tell you about situations when it is advantageous to promote a pawn to pieces other than the queen. This is illustrated with interesting and instructive examples.

Chess pieces are divided into light and heavy. Lungs - horses and elephants. Heavy - rooks and queen. The king is not a light or heavy figure (simply the most important). Pawns are not pieces at all.

Chessboard and pieces

A chess game is played by two opponents 1 on 1. One player controls the white pieces, the other controls the black ones. The game takes place on a square board, each side of which consists of 8 cells, or fields. Accordingly, the total number of cells is 8x8=64. To make it easier to distinguish the boundaries of the fields, they are painted alternately in light and dark colors. For simplicity, light fields are called white fields, and dark fields are called black fields. There is always a black field in the lower left corner of the board:

Vertical columns of fields are designated by Latin letters from a to h. And the horizontal rows are numbers from 1 to 8. Accordingly, each field of the board can be designated by the letter of the vertical and the number of the horizontal at the intersection of which it is located. For example, b3, d5, f2, h6, etc. In addition to verticals and horizontals, there are also diagonals - field lines at an angle of 45 degrees. To call a diagonal, we say the starting and ending fields. For example, diagonal a1-h8, diagonal h3-c8, etc.

Each player has 8 pieces (king, queen, two rooks, two bishops, two knights) and 8 pawns:

The initial arrangement of the pieces on the board, or the so-called. starting position:

Piece moves and captures.

The game consists of moving pieces around the board, or moves. The moves are made one by one. White makes the first move in the game. A move may consist of capturing an opponent's piece other than the king. At the same time, it is removed from the board, and the piece that captured is placed in the place of the captured piece. Let's look at how each of the figures moves.

King

The king can move to any one square adjacent to himself vertically, horizontally and diagonally.


Queen

The queen moves to any number of squares vertically, horizontally and diagonally.

Rook

The rook moves vertically and horizontally.

Elephant

The bishop moves only diagonally.

Obviously, a bishop standing on a white square cannot in any way get onto a black square, no matter how many and what moves it makes. And vice versa. Looking at the initial position, you will see that each side has one bishop moving on white squares, the other on black squares. Accordingly, one bishop is called light-squared, the other - dark-squared.

Horse

This figure has an unusual move. The horse moves in the letter "G". More precisely, on the field located “at the tip” of this imaginary letter: two cells vertically or horizontally, plus one cell sideways. Look at the diagram and then everything will become clear:

Pieces cannot “jump over” other pieces, their own or others. The horse can. For example, in this diagram, even if there are some pieces or pawns on squares c4, c3, d3, the knight can still go to b3 or c2 (Unless, of course, b3 and c2 are occupied by their own pieces. If they are strangers, then they can be taken) .

Pawn

A pawn can only move one square forward. Pawns don't move back. In the starting position you have a choice: go 1 or 2 fields forward.


Special Moves

Castling

Castling is a simultaneous move of the king and rook. It is possible if both pieces are in the starting position. The king moves two squares towards the rook. The rook occupies the square that the king "jumped over". Depending on which direction the castling is made, it can be short or long. The diagram shows, as an example, the final position of the king and rook with white castling long and black castling short:

Castling is not possible in the following cases:

1) The king or rook participating in the game has already been played in the game
2) The king is in check (see below)
3) After castling, the king falls into check
4) Between the king and the rook participating in castling there is one’s own or someone else’s piece
5) The king (but not the rook) crosses a square attacked by an opponent’s piece

Castling is the most unusual move in chess. Beginners are often confused about when castling is possible and when it is not. For better remembering, let's give a clear example:


Let's assume that neither the white nor the black king, nor any of the rooks have yet moved in the game. Then White can castle short. They cannot castle long, since after the move is completed the white king will be on c1 under the attack of the black queen g5. Black cannot castle short, since in this case the black king would cross the f8 square, which is controlled by the white queen a3. Black can castle on the long side. Please note: the fact that the rook a8 is under the attack of the bishop g2, and the square b8 is under the attack of the bishop g3, does not in any way interfere with castling.

Taking on the pass

If a pawn, having made a move 2 squares from its initial position, becomes next to the enemy’s pawn, then it can be captured “on the pass”, since it has passed the square under the attack of this pawn.

Suppose that in a position on the diagram, White makes a pawn move from c2 to c4. In this case, Black can take the pawn en passant if he wishes. In this case, the black pawn will move to square c3, and the white pawn will disappear from the board.

The right to such a capture can only be exercised immediately in response to a double pawn move. In the future, this right is lost.

Pawn promotion

If a pawn steps on the last rank (for white - on the eighth, for black - on the first), then it must be transformed into one of the pieces of its color: queen, rook, bishop or knight. The choice of piece does not depend on what pieces are currently on the board. The pawn is removed from the board and replaced with a new piece on the same square.

The purpose of the game and possible options for ending the game

The main figure in chess is the king. According to the rules, they are not allowed to go onto the field beaten by their opponents. An attack on the king is called check. Under Shah, the party to whom he was declared is obliged to protect the king. For example, move it to another square (not under fire from enemy pieces), or destroy an enemy piece that gives check, or place your piece on the line between the attacking piece and the king. If none of the methods is possible, then on the board mat, and the game immediately ends with the victory of the side that declared it. Checkmate implies that the opponent's king would inevitably be captured on the next move. Thus, the final The goal of the game is to declare checkmate the opponent's king.

Here are a few examples in which White declared checkmate.