Answers.Body: <p>One thing you must understand is that any chess engine using negamax/minimax with alpha-beta pruning and other heuristics uses a <a href="https://hxim.github.io/Stockfish-Evaluation-Guide" rel="nofollow noreferrer">static evaluation function</a> at the leaves of the search-tree. This function returns terminal values (e.g. win-in-0, loss-in-0, draw-in-0), or estimates of 'position value' when the game has not ended, and these values propagate up the search-tree. The engine eventually chooses a move that maximizes the guaranteed value of a leaf that it can reach in that tree no matter what the opponent does. Now, of course there is no doubt about win-in-k or loss-in-k values; if any <strong>correct</strong> engine evaluates a position to have such a value, it means it has <em>proven</em> that the indicated side can guarantee a win within k moves. The question is what do other values mean.</p>
  <p>SF uses some big value M (≈64) to indicate almost sure win (overwhelming advantage), which shows up especially when one side will have an unstoppable pawn promotion and the other side has too little material. As per the above explanation, if SF evaluates a position to have value ≈ M or ≈ −M, that value implies guaranteed almost sure win for the indicated side. SF also has other 'tiers' for different levels of confidence.</p>
  <p>But besides these coarse 'tiers' SF also has fine-tuned heuristic factors that are evaluated to add little bits of 'positional value' to each side, such as king-danger and bishop-pair. These do not correspond directly to material, but the values have been tuned so that SF makes the correct decision with the highest frequency that its designers could achieve using those heuristic factors. At least this is what is happening with SF10.</p>
  <p>In fact, although each piece is given a value (piece-value-bonus), even this value changes over time (piece-value-mg to piece-value-eg), and the square it is on is also taken into account (piece-square-bonus), along with many other things. So it is hard to even say that +1.3 represents roughly 1.3 pawns. Not at all, really.</p>
  <p>So there is <strong>not really any material meaning</strong> to an evaluation of +1.3 by SF10. Rather:</p>
  <ul>
  <li>SF10 has searched a tree T and found that <strong>if</strong> both players only make moves given in that tree T <strong>then</strong> White can guarantee to reach a leaf node of T with static evaluation value at least +1.3 <strong>and</strong> Black can guarantee to reach a leaf node of T with static evaluation value at most +1.3.</li>
  <li>In extensive testing, it is found that <em>generally</em> SF10 performs better with the weights it uses in its heuristics than with other weights. It does often mean that a position with higher static evaluation than another position is more likely to be better for White, but it can be very wrong, for example in this position:</li>
  </ul>
  <pre><code>[Title &quot;Bad for Black&quot;]
  [FEN &quot;q1k5/PpP2ppp/1Pp5/2N5/8/8/7P/K7 w - - 0 1&quot;]
  </code></pre>
  <p>The static evaluation for this position (you can try using the link above) is solidly in Black's favour, but it is wrong! This shows that the static evaluation of leaves of the search-tree can be very inaccurate. However, this problem is mitigated strongly by the search-tree itself! Since SF never plays based only on static evaluation only, its chosen move tends to be correct simply because incorrectly evaluated leaves are rare. The primary approach is <strong>quiescence search</strong>, which extends the search-tree at nodes that are deemed to be not quiet (e.g. just after check or capture), and hence usually avoids erroneous evaluation based on a misleading material balance in the middle of a piece exchange. This approach does not help in the position I showed above, and <a href="https://lichess.org/analysis/q1k5/PpP2ppp/1Pp5/2N5/8/8/7P/K7_w_-_-_0_1" rel="nofollow noreferrer">SF10 depth 20 on Lichess evaluates it at ≈ −3</a>.</p>
  <p>But SF10 will rarely get into such problematic positions in the first place! This is because quiescence search ensures that the vast majority of leaf nodes of the search-tree have roughly correct <strong>relative</strong> static evaluations (and here all the tiny bits help), and so choosing the best move based on that tree not only almost always turns out to be the best move but also almost always avoids subtrees where the future search would have many such problematic positions at the search-tree leaves! For instance, to get to the above illustrated position Black not only has to hide the queen in a corner but also get the king stuck! This is very heavily disfavoured by many of the heuristic factors including king-danger and piece-mobility <em>at earlier moves</em>, so SF10 would never even <em>have</em> to evaluate such problematic positions in the first place.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T10:45:02.660Z
Answers.Text: Note: This answer does not talk about NNUE, which is another kind of static evaluation heuristic that is even more of a black box and harder to explain.
Answers.UserDisplayName: user21820
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-13T15:05:30.187Z
Answers.Text: Are you sure Stockfish uses M to indicate an overwhelming advantage? I'm under the impression an MX eval means mate in X moves.
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-13T15:45:25.417Z
Answers.Text: @Allure: Please read the preceding paragraph, where I wrote about "win-in-k or loss-in-k values" (which are what you are thinking about), and then said "The question is what do **other** values mean.". Just look through any game in which at some point SF figures out that there is an unstoppable pawn promotion (to a queen that cannot be captured) but cannot yet *prove* a win/loss, and you will see the evaluation suddenly jump to ±M where M ≈ 64.
Answers.UserDisplayName: user21820
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T10:39:35.817Z
Answers.LastActivityDate: 2021-11-12T10:39:35.817Z
Answers.UserDisplayName: user21820
Answers.Body: <p>Chess engines search the game tree and return the evaluation of the best final position in the tree. The evaluation corresponds to the static evaluation (i.e. the evaluation function of the engine evaluated on that position), regardless of whether it is a NN evaluation, a NNUE evaluation, or a handcrafted evaluation function. There is no &quot;future-looking&quot;. Evaluation functions cannot look into the future; that is what the search algorithm does.</p>
  <p>I'm guessing a lot of your confusion stems from the fact that engine evaluations have long passed the point of just counting material. It factors in the locations of the pieces, king safety, pawn structure, whether there are opposite color bishops on the board, and a whole lot of other factors.</p>
  <p>Finally, some evaluation functions don't actually return a +x.xx centipawn eval. They return a win percentage, that is, an estimate of how likely it is that they will win from that position. That estimate is then converted to centipawns with a formula that depends on the engine, e.g. Leela's conversion from win % to centipawns is cp = 90 * tan(1.5637541897 * q), where q = win probability + draw probability*drawscore - loss probability [1]. If you are having trouble understanding centipawn eval, it might be more helpful to think of it as a win percentage.</p>
  <p>[1] &quot;drawscore&quot; is a factor which allows you to influence how Leela treats draws. A negative drawscore for example pushes the engine to avoid draws, because draws would add a negative amount to the eval. It is similar to contempt in traditional engines.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T03:45:58.477Z
Answers.Text: (1) Thanks! I didn't know that sometimes it refers to a win percentage, which is interesting, and that seems sufficiently specific to start to think about how to implement predictions. But I guess my confusion is sort of the inverse of what you mentioned. I understand that the advantage is not material based, but the unit ("centipawns", as you mention) are clearly expressed in terms of material. So my confusion is how to translate non-material advantage, such as a percentage-win-based advantage, into a material-based metric/unit of advantage. I don't understand that step.
Answers.UserDisplayName: badroit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T03:46:52.717Z
Answers.Text: (2) Also I am a bit confused how non-material advantage can be considered without it being "future-looking".
Answers.UserDisplayName: badroit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T03:50:35.050Z
Answers.Text: @badroit you put the win-draw-lose percentages into a formula that yields what you consider are reasonable numbers, and calculate from there. A formula is given in the third paragraph of answer. As for how non-material advantage can be considered without being future-looking, for example, take a White knight that's on the d6-square. This is usually a good place for White to have a knight, so I assign a bonus, especially if the d6-square is supported by a White pawn and it cannot be attacked by Black pawns.
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T03:54:02.393Z
Answers.Text: @badroit for an example, take a look at PeSTO's evaluation function. https://www.chessprogramming.org/PeSTO%27s_Evaluation_Function There's a table named "mg_knight_table[64]" (mg stands for middlegame). You can see it's an 8x8 table, corresponding to the 64 squares on a chessboard. Positive numbers add value for White, negative values are penalties. The first number, -167, indicates that PeSTO assigns a penalty to a White knight on a8. Conversely, the highest number (129) is for a White knight on f6.
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T03:55:00.017Z
Answers.Text: This doesn't mean PeSTO deducts centipawns from the eval if White's knight is on a8, of course. A White knight on a8 still adds something to White's score, it just adds less than its full material value.
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T10:48:01.270Z
Answers.Text: @badroit: See my answer and the linked StockFish static evaluation guide to see how SF10 really works, in particular how it accounts for non-material advantage *without actually looking into the future*.
Answers.UserDisplayName: user21820
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-17T06:11:43.620Z
Answers.Text: Thanks Allure. Both answers I found more or less equally useful, so I accepted the more detailed one as a "tie breaker". My understanding now is that (1) the evaluation has no fixed semantics; (2) the implementation varies from engine-to-engine; (3) the scores themselves tend to rely either on hand-crafted heuristics or win probabilities; (4) the centi-pawn unit is used in a pretty liberal/didactic sense.
Answers.UserDisplayName: badroit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-12T00:21:17.650Z
Answers.LastActivityDate: 2021-11-12T02:38:05.560Z
Answers.LastEditDate: 2021-11-12T02:38:05.560Z
Answers.UserDisplayName: Allure
Answers.Body: <p>The evaluation is based on general results from the engine’s tablebase. It thinks by positional means, and looks forward a few moves. It looks in its programmed tables and sees, ‘Ah, an open file is worth about .5 pawns (for example).’ Then it sees if it is also in this case a .5 advantage, and using this for many more details in the position, the computer calculates the approximate advantage for white or black.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-31T04:51:51.383Z
Answers.Text: That's not what a tablebase is.
Answers.UserDisplayName: Oscar Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-30T09:21:05.307Z
Answers.LastActivityDate: 2021-12-30T09:21:05.307Z
Answers.UserDisplayName: Jisu101
Body: <p>I know that chess engine evaluations like +1.3 intuitively mean that White is evaluated to have an advantage equivalent to 1.3 pawns of material, or that -3.2 means that Black is evaluated to have an advantage equivalent to a little over a knight or bishop. But I am struggling to pin down what &quot;having an advantage equivalent to&quot; really means or how it could be implemented.</p>
  <p>Such evaluations do not simply count the material on the board, but rather might translate into such an advantage <em>in future</em>. For example, an evaluation of -3.2 might be because Black, through optimal play, can force the capture of a white Bishop &quot;for free&quot; in the next couple of moves.</p>
  <p>Other cases might not be so clearly linked to material advantage. For example, although currently level in material, Black, through optimal play, may gain a strong tactical advantage <em>in future</em> due to the white King being open.</p>
  <p>My doubt here is that an engine will inevitably turn a -3.2 advantage into a future win for Black, even if the full path to checkmate is not clear. So the further we look into the future, the stronger the advantage will inevitably become for Black.</p>
  <p>Hence my confusion. It seems that there is some &quot;future looking&quot; aspect to the evaluations, but depending on how far into the future we look, the evaluation for the current position changes.</p>
  <p>Trying to &quot;backwards-engineer&quot; the concept, it seems that maybe there is a fixed window of turns somehow in which the advantage is considered, but this again seems material-based whereas an advantage might never translate into a material advantage in the short term. Perhaps another way would be to consider how much material must be given to the other side right now in order to make the position equal, but then there's the question of what material, and where to place that material.</p>
  <p>Chess engines (not based on supervised learning at least) must implement this evaluation function in some way, and I guess that there is some standard definition in order to make the scores of different engines comparable (though I might be wrong).</p>
  <p>My question is: is there a standard/typical, rigorous definition for these chess engine evaluations, and if so, what is that definition?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T23:16:06.883Z
Comments.Text: Each engine has its own evaluation function, but it's often tuned so that an abstract, ideal "one pawn advantage" is +1
Comments.UserDisplayName: David
Tags: <engines><evaluation>
Title: What do chess engine evaluation scores (+1.3, -3.2) really mean?
ThreadText: # What do chess engine evaluation scores (+1.3, -3.2) really mean?
  
  (Asked by: username_0 on 2021-11-11)
  
  I know that chess engine evaluations like +1.3 intuitively mean that White is evaluated to have an advantage equivalent to 1.3 pawns of material, or that -3.2 means that Black is evaluated to have an advantage equivalent to a little over a knight or bishop. But I am struggling to pin down what "having an advantage equivalent to" really means or how it could be implemented.
  
  Such evaluations do not simply count the material on the board, but rather might translate into such an advantage *in future*. For example, an evaluation of -3.2 might be because Black, through optimal play, can force the capture of a white Bishop "for free" in the next couple of moves.
  
  Other cases might not be so clearly linked to material advantage. For example, although currently level in material, Black, through optimal play, may gain a strong tactical advantage *in future* due to the white King being open.
  
  My doubt here is that an engine will inevitably turn a -3.2 advantage into a future win for Black, even if the full path to checkmate is not clear. So the further we look into the future, the stronger the advantage will inevitably become for Black.
  
  Hence my confusion. It seems that there is some "future looking" aspect to the evaluations, but depending on how far into the future we look, the evaluation for the current position changes.
  
  Trying to "backwards-engineer" the concept, it seems that maybe there is a fixed window of turns somehow in which the advantage is considered, but this again seems material-based whereas an advantage might never translate into a material advantage in the short term. Perhaps another way would be to consider how much material must be given to the other side right now in order to make the position equal, but then there's the question of what material, and where to place that material.
  
  Chess engines (not based on supervised learning at least) must implement this evaluation function in some way, and I guess that there is some standard definition in order to make the scores of different engines comparable (though I might be wrong).
  
  My question is: is there a standard/typical, rigorous definition for these chess engine evaluations, and if so, what is that definition?
  
  **Tags:** engines, evaluation
  
  > **Comments:**
  > **username_1**: Each engine has its own evaluation function, but it's often tuned so that an abstract, ideal "one pawn advantage" is +1  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2021-11-12. Score: 4 | Accepted answer
  
  One thing you must understand is that any chess engine using negamax/minimax with alpha-beta pruning and other heuristics uses a [static evaluation function](https://hxim.github.io/Stockfish-Evaluation-Guide) at the leaves of the search-tree. This function returns terminal values (e.g. win-in-0, loss-in-0, draw-in-0), or estimates of 'position value' when the game has not ended, and these values propagate up the search-tree. The engine eventually chooses a move that maximizes the guaranteed value of a leaf that it can reach in that tree no matter what the opponent does. Now, of course there is no doubt about win-in-k or loss-in-k values; if any **correct** engine evaluates a position to have such a value, it means it has *proven* that the indicated side can guarantee a win within k moves. The question is what do other values mean.
  
  SF uses some big value M (≈64) to indicate almost sure win (overwhelming advantage), which shows up especially when one side will have an unstoppable pawn promotion and the other side has too little material. As per the above explanation, if SF evaluates a position to have value ≈ M or ≈ −M, that value implies guaranteed almost sure win for the indicated side. SF also has other 'tiers' for different levels of confidence.
  
  But besides these coarse 'tiers' SF also has fine-tuned heuristic factors that are evaluated to add little bits of 'positional value' to each side, such as king-danger and bishop-pair. These do not correspond directly to material, but the values have been tuned so that SF makes the correct decision with the highest frequency that its designers could achieve using those heuristic factors. At least this is what is happening with SF10.
  
  In fact, although each piece is given a value (piece-value-bonus), even this value changes over time (piece-value-mg to piece-value-eg), and the square it is on is also taken into account (piece-square-bonus), along with many other things. So it is hard to even say that +1.3 represents roughly 1.3 pawns. Not at all, really.
  
  So there is **not really any material meaning** to an evaluation of +1.3 by SF10. Rather:
  
  * SF10 has searched a tree T and found that **if** both players only make moves given in that tree T **then** White can guarantee to reach a leaf node of T with static evaluation value at least +1.3 **and** Black can guarantee to reach a leaf node of T with static evaluation value at most +1.3.
  * In extensive testing, it is found that *generally* SF10 performs better with the weights it uses in its heuristics than with other weights. It does often mean that a position with higher static evaluation than another position is more likely to be better for White, but it can be very wrong, for example in this position:
  
  ```
  [Title "Bad for Black"]
  [FEN "q1k5/PpP2ppp/1Pp5/2N5/8/8/7P/K7 w - - 0 1"]
  
  ```
  
  The static evaluation for this position (you can try using the link above) is solidly in Black's favour, but it is wrong! This shows that the static evaluation of leaves of the search-tree can be very inaccurate. However, this problem is mitigated strongly by the search-tree itself! Since SF never plays based only on static evaluation only, its chosen move tends to be correct simply because incorrectly evaluated leaves are rare. The primary approach is **quiescence search**, which extends the search-tree at nodes that are deemed to be not quiet (e.g. just after check or capture), and hence usually avoids erroneous evaluation based on a misleading material balance in the middle of a piece exchange. This approach does not help in the position I showed above, and [SF10 depth 20 on Lichess evaluates it at ≈ −3](https://lichess.org/analysis/q1k5/PpP2ppp/1Pp5/2N5/8/8/7P/K7_w_-_-_0_1).
  
  But SF10 will rarely get into such problematic positions in the first place! This is because quiescence search ensures that the vast majority of leaf nodes of the search-tree have roughly correct **relative** static evaluations (and here all the tiny bits help), and so choosing the best move based on that tree not only almost always turns out to be the best move but also almost always avoids subtrees where the future search would have many such problematic positions at the search-tree leaves! For instance, to get to the above illustrated position Black not only has to hide the queen in a corner but also get the king stuck! This is very heavily disfavoured by many of the heuristic factors including king-danger and piece-mobility *at earlier moves*, so SF10 would never even *have* to evaluate such problematic positions in the first place.
  
  > **Comments:**
  > **username_2**: Note: This answer does not talk about NNUE, which is another kind of static evaluation heuristic that is even more of a black box and harder to explain.  
  > **username_3**: Are you sure Stockfish uses M to indicate an overwhelming advantage? I'm under the impression an MX eval means mate in X moves.  
  > **username_2**: @username_3: Please read the preceding paragraph, where I wrote about "win-in-k or loss-in-k values" (which are what you are thinking about), and then said "The question is what do **other** values mean.". Just look through any game in which at some point SF figures out that there is an unstoppable pawn promotion (to a queen that cannot be captured) but cannot yet *prove* a win/loss, and you will see the evaluation suddenly jump to ±M where M ≈ 64.  
  
  ---
  
  ### Answer by username_3 on 2021-11-12. Score: 3
  
  Chess engines search the game tree and return the evaluation of the best final position in the tree. The evaluation corresponds to the static evaluation (i.e. the evaluation function of the engine evaluated on that position), regardless of whether it is a NN evaluation, a NNUE evaluation, or a handcrafted evaluation function. There is no "future-looking". Evaluation functions cannot look into the future; that is what the search algorithm does.
  
  I'm guessing a lot of your confusion stems from the fact that engine evaluations have long passed the point of just counting material. It factors in the locations of the pieces, king safety, pawn structure, whether there are opposite color bishops on the board, and a whole lot of other factors.
  
  Finally, some evaluation functions don't actually return a +x.xx centipawn eval. They return a win percentage, that is, an estimate of how likely it is that they will win from that position. That estimate is then converted to centipawns with a formula that depends on the engine, e.g. Leela's conversion from win % to centipawns is cp = 90 \* tan(1.5637541897 \* q), where q = win probability + draw probability\*drawscore - loss probability [1]. If you are having trouble understanding centipawn eval, it might be more helpful to think of it as a win percentage.
  
  [1] "drawscore" is a factor which allows you to influence how Leela treats draws. A negative drawscore for example pushes the engine to avoid draws, because draws would add a negative amount to the eval. It is similar to contempt in traditional engines.
  
  > **Comments:**
  > **username_0**: (1) Thanks! I didn't know that sometimes it refers to a win percentage, which is interesting, and that seems sufficiently specific to start to think about how to implement predictions. But I guess my confusion is sort of the inverse of what you mentioned. I understand that the advantage is not material based, but the unit ("centipawns", as you mention) are clearly expressed in terms of material. So my confusion is how to translate non-material advantage, such as a percentage-win-based advantage, into a material-based metric/unit of advantage. I don't understand that step.  
  > **username_0**: (2) Also I am a bit confused how non-material advantage can be considered without it being "future-looking".  
  > **username_3**: @username_0 you put the win-draw-lose percentages into a formula that yields what you consider are reasonable numbers, and calculate from there. A formula is given in the third paragraph of answer. As for how non-material advantage can be considered without being future-looking, for example, take a White knight that's on the d6-square. This is usually a good place for White to have a knight, so I assign a bonus, especially if the d6-square is supported by a White pawn and it cannot be attacked by Black pawns.  
  > **username_3**: @username_0 for an example, take a look at PeSTO's evaluation function. https://www.chessprogramming.org/PeSTO%27s_Evaluation_Function There's a table named "mg_knight_table[64]" (mg stands for middlegame). You can see it's an 8x8 table, corresponding to the 64 squares on a chessboard. Positive numbers add value for White, negative values are penalties. The first number, -167, indicates that PeSTO assigns a penalty to a White knight on a8. Conversely, the highest number (129) is for a White knight on f6.  
  > **username_3**: This doesn't mean PeSTO deducts centipawns from the eval if White's knight is on a8, of course. A White knight on a8 still adds something to White's score, it just adds less than its full material value.  
  > **username_2**: @username_0: See my answer and the linked StockFish static evaluation guide to see how SF10 really works, in particular how it accounts for non-material advantage *without actually looking into the future*.  
  > **username_0**: Thanks username_3. Both answers I found more or less equally useful, so I accepted the more detailed one as a "tie breaker". My understanding now is that (1) the evaluation has no fixed semantics; (2) the implementation varies from engine-to-engine; (3) the scores themselves tend to rely either on hand-crafted heuristics or win probabilities; (4) the centi-pawn unit is used in a pretty liberal/didactic sense.  
  
  ---
  
  ### Answer by username_4 on 2021-12-30. Score: -1
  
  The evaluation is based on general results from the engine’s tablebase. It thinks by positional means, and looks forward a few moves. It looks in its programmed tables and sees, ‘Ah, an open file is worth about .5 pawns (for example).’ Then it sees if it is also in this case a .5 advantage, and using this for many more details in the position, the computer calculates the approximate advantage for white or black.
  
  > **Comments:**
  > **username_5**: That's not what a tablebase is.  
  
  ---
  
  