Answers.Body: <p>Please note that those values are "abstract", later to be modified by the specifics of the position. For example, even though a knight appears 0.8 pawns less valuable than a bishop, it could be that bigger bonuses are awarded to well-placed knights than for well-placed bishops, turning the balance around.</p>
  
  <p>It's also worth noting that the "3 pawns equal a piece" is, for all practical purposes, meaningless. In certain types of positions (those with powerful attacks against the king, for instance), the extra pawns can be useless against a piece. In endgames, three pawns often defeat the piece, specially if not a lot of extra pawns are left</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T02:07:33.030Z
Answers.Text: I think this is the big one: the modifiers to those numbers may be so significant as to render the base numbers kind of meaningless.
Answers.UserDisplayName: Steve Bennett
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-09T23:24:14.243Z
Answers.LastActivityDate: 2020-05-09T23:24:14.243Z
Answers.UserDisplayName: David
Answers.Body: <p>The value of a piece or pawn will depend greatly upon how well it is placed.  The common 1/3/3.5/5/9 values are reasonable estimates for pieces which are placed decently but not amazingly well.  For various reasons, it may be easier to have the baseline score for a piece represent a piece which is either much worse than typical (so that most pieces would have an adjusted score that was higher), or perhaps have it represent a piece which is much better than typical (so that most pieces would score lower).  As an exaggerated contrived example, consider something like:</p>
  
  <pre><code>8/p/Pp/RP/1P2nn/RP/P/5K1k w - - 0 1
  </code></pre>
  
  <p>Even though White nominally has a substantial material advantage (up twice the Exchange, plus three pawns), Black cannot lose without capturing any of the White pawns or pieces.  Although trading a pawn for a rook would normally be a good trade, in this case it is a very bad one since White's pieces are completely useless.  Black will nominally be able to trade a pawn for a rook, which would seem like an advantage, but doing so would enormously increase the value of White's pieces.</p>
  
  <p>If it is White to mov
  Playing with this example, I think White should be able to eke out a draw, and Black certainly should be able to do at least that.  Playing against Stockfish level 3 on lichess.org, however, I was able to win as both sides because Stockfish overvalued the material at the left and thinks it's worth trading for (I think White should be able to eke out a draw by moving R3-a4, and then a3, but Stockfish didn't find that playing as White, and there might be a way for Black to capture the rook in a situation where Black could then forcce draw by perpetual check/repetition, but Black should have no excuse for losing here.</p>
  
  <p>Even in less contrived situations, Stockfish sometimes fails to adequately distinguish between pieces which aren't currently in the fray, but are going to get there, versus pieces which can be very cheaply kept out of the action while the opponent has a substantial majority of the immediately-effective material.  A common feature of games between neural networks and Stockfish is that Stockfish ends up letting some of its pieces sit out of the action while the opponent uses its power majority to edge out further advantages, until by the time the blocked-up pieces get to move, the game is already lost.</p>
  
  <p>Incidentally, I was just playing with another variation on that example (black to play)</p>
  
  <pre><code>7K/p7/Pp6/RP6/QP4q1/RP3k2/P7/8 b - - 0 1
  </code></pre>
  
  <p>Black has a mate in four, but Stockfish, even if set for the highest level on lichess.org, will stalemate White via Qg6 rather than achieve victory, probably because any move that continues play with such a large material imbalance is seen as so massively inferior to stalemate that it's not worth investigating further.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T00:56:04.037Z
Answers.Text: Uh, in that last example, how does black force a win? "move the king to g4", then white replies with Kg1 and it's a draw anyway (e.g. Kg4, Kg1 Kh3, Kh1 g2, Kg1 Kg3)? Stockfish probably goes for the draw because it is a draw, unless I'm missing something?
Answers.UserDisplayName: ZLK
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T15:23:04.623Z
Answers.Text: @ZLK: Any idea why Stockfish level 8 on lichess would do Kf1 rather than Kh1 in that line?
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T15:44:52.547Z
Answers.Text: @ZLK: I think I figured out why Stockfish was never so impertinent as to play Kh1.  Even if Black manages to promote the pawn, White would still be ahead by two rooks and three pawns, so a stalemate would be seen as a bad outcome for White.
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T22:28:09.990Z
Answers.Text: @ZLK: I reworked the example to show even more clearly that Stockfish is overvaluing pieces that can't move.  Black can immediately achieve a draw, and no position that can be reached within three moves would offer prospects that aren't much worse.  I don't think Stockfish's behavior necessarily represents a "defect", in that improving play in this sort of contrived situation would require spending more time pursuing lines that would be unlikely to be useful outside such contrived situations.  Still interesting, though, that SF would be blind to a mate in four where all of White's moves...
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-11T22:29:09.867Z
Answers.Text: ...are either forced or, in the one case where White would have a choice, the one alternative move would allow immediate mate.
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T04:26:58.100Z
Answers.Text: In that last example, my Stockfish finds the mate in less than a second (?)
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-16T14:04:57.497Z
Answers.Text: @Allure: The Stockfish on LiChess has limited configuration options, and its configuration is probably set to just barely prune the key move even on its highest setting.  I wanted to tweak the example to show how far the evaluation could be pushed, but to make it work with other configurations the mate may need to be pushed further out (e.g. perhaps by moving Black's king to c8 instead of c6).
Answers.UserDisplayName: supercat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-09T21:14:04.693Z
Answers.LastActivityDate: 2020-05-11T20:12:00.373Z
Answers.LastEditDate: 2020-05-11T20:12:00.373Z
Answers.UserDisplayName: supercat
Answers.Body: <p>I'm afraid it was machine tuned. Nobody knows exactly why. It's like nobody really understand the network weights in LC0. In any case, 3 pawns = a piece is nothing more than a general guidance for chess beginners.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-09T19:54:55.737Z
Answers.Text: I think there is more to it (see my too long answer). If a piece was really worth 6 pawns, I doubt stockfish would play as good.
Answers.UserDisplayName: user1583209
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-09T15:10:21.003Z
Answers.LastActivityDate: 2020-05-09T15:10:21.003Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>I am not an expert on stockfish source code, but my understanding is the following.</p>
  
  <p>Humans:</p>
  
  <p>It is true, that the  <em>1 piece equals 3 pawns approach</em> is pretty accurate, surprisingly so. However as you are probably aware, when evaluating a position, we consider many other aspects as well, such as piece activity, space, king safety, etc. The difference however is that <strong>we don't assign actual numerical values to these other factors.</strong> </p>
  
  <p>Stockfish (or similar engines):</p>
  
  <p>Unlike humans, engines assign numerical values to all factors. The numbers you mention are just <strong>a small part of the evaluation function.</strong></p>
  
  <p>Check out the <a href="https://hxim.github.io/Stockfish-Evaluation-Guide/" rel="noreferrer">middlegame evaluation function</a> for stockfish. On that page you can also modify the board to see the evaluation and you can visit the specific functions such as `piece_value_mg' which is concerned with these numbers.</p>
  
  <p>As you can see, just the piece values of all pieces amount to 9326. However there are many other functions which add to the evaluation. Most importantly, <strong>not all of these extra functions treat pawns and pieces equally.</strong> </p>
  
  <p>For instance: </p>
  
  <ul>
  <li>`Psqt mg', gives values to pawns only, depending on their position on the board. As you would expect,  pawns in the center are more valuable (pawn on e4 instead of e2 is +24 points)</li>
  <li>another pawns only function: `Pawns mg' gives points depending on the pawn structure (isolated, doubled, connected pawns, etc) also here you can gain several tenth of points for the pawns (but not for the pieces).</li>
  </ul>
  
  <p>To be fair, there are also functions that only deal with pieces such as `Pieces mg'. However note that they can also give a penalty (negative value) to the total evaluation. In fact for the starting position you have -63 from that function.</p>
  
  <hr>
  
  <p>In summary...</p>
  
  <p>Stockfish has a much more fine grained evaluation function than we humans do. The pure piece value from stockfish cannot really be compared with the human piece value.</p>
  
  <p>In stockfish pieces and pawns can gain points in other ways beyond the values you mention. Furthermore, stockfish does not consider the piece on its own, but also how it relates to other pieces, e.g. whether there are doubled pawns, an outpost, etc.</p>
  
  <p>If you check out the code, these other factors are each in the range of several ten points, so if you take them all together you might very well gain the 100 points necessary for the pawn to be 1/3 of a piece.</p>
  
  <p>Mathematically you could also consider it as a kind of approximation or averaging in which you assign a single number (human piece value) for the very complex system that stockfish uses. There is no reason that the average value (human piece value) has any relation to one of the parameters (ValueMG) in the stockfish universe.</p>
  
  <p>I really recommend to see for yourself at the link how much more complete the stockfish evaluation is.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-10T23:59:34.523Z
Answers.Text: +1 Excellent answer.
Answers.UserDisplayName: Inertial Ignorance
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-09T19:46:30.347Z
Answers.LastActivityDate: 2020-05-09T19:46:30.347Z
Answers.UserDisplayName: user1583209
Body: <p>I was taking a look at values engines give to pawns and piece and was quite shocked by <a href="https://github.com/official-stockfish/Stockfish/blob/master/src/types.h#L182-L186" rel="noreferrer">Stockfish values for middlegame (Mg)</a>:</p>
  
  <ul>
  <li><p><code>PawnValueMg</code>   = 128</p></li>
  <li><p><code>KnightValueMg</code> = 721 ~ 5.6 pawns</p></li>
  <li><p><code>BishopValueMg</code> = 825 ~ 6.4 pawns</p></li>
  <li><p><code>RookValueMg</code>   = 1276 ~ 9.9 pawns</p></li>
  <li><p><code>QueenValueMg</code>  = 2538 ~ 19.8 pawns</p></li>
  </ul>
  
  <p>So this is way far from the standard "1 piece equals 3 pawns approach", and I was curious about the reason behind it.</p>
  
  <p>Also, the fact that bishops are 0.8 pawns more valuable than knights called my attention.</p>
  
  <p>I'm aware that this is a small part of Stockfish's (or for that case, any serious engine) evaluation function, but even so it seems like a really big different from the classic approach. </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-09T12:48:48.863Z
Comments.Text: I'm pretty sure the values are empirically tuned. To explain why - as in 'why is a Bishop worth 0.8 pawns more than knights in the generic middlegame position - though is likely beyond the ability of anyone on the planet. It works, that's all anyone knows.
Comments.UserDisplayName: Allure
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-09T14:55:08.037Z
Comments.Text: "It works" means "it works in the context of Stockfish evaluation algorithm". That doesn't mean it would work for humans!
Comments.UserDisplayName: kjetil b halvorsen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-11T09:32:14.057Z
Comments.Text: The rule of thumb is 3 pawns in a knight/bishop. But that's a simplification. A bishop is almost always worth more than a knight and both pieces are almost always worth more than 3 pawns. That rule works for a simplification, but Stockfish doesn't care for simplifications.
Comments.UserDisplayName: Mast
Tags: <engines><stockfish><evaluation><pieces><point-value>
Title: Why does Stockfish undervalue pawns when compared to the classical "a piece is worth three pawns" approach?
ThreadText: # Why does Stockfish undervalue pawns when compared to the classical "a piece is worth three pawns" approach?
  
  (Asked by: username_0 on 2020-05-09)
  
  I was taking a look at values engines give to pawns and piece and was quite shocked by [Stockfish values for middlegame (Mg)](https://github.com/official-stockfish/Stockfish/blob/master/src/types.h#L182-L186):
  
  * `PawnValueMg` = 128
  * `KnightValueMg` = 721 ~ 5.6 pawns
  * `BishopValueMg` = 825 ~ 6.4 pawns
  * `RookValueMg` = 1276 ~ 9.9 pawns
  * `QueenValueMg` = 2538 ~ 19.8 pawns
  
  So this is way far from the standard "1 piece equals 3 pawns approach", and I was curious about the reason behind it.
  
  Also, the fact that bishops are 0.8 pawns more valuable than knights called my attention.
  
  I'm aware that this is a small part of Stockfish's (or for that case, any serious engine) evaluation function, but even so it seems like a really big different from the classic approach.
  
  **Tags:** engines, stockfish, evaluation, pieces, point-value
  
  > **Comments:**
  > **username_1**: I'm pretty sure the values are empirically tuned. To explain why - as in 'why is a Bishop worth 0.8 pawns more than knights in the generic middlegame position - though is likely beyond the ability of anyone on the planet. It works, that's all anyone knows.  
  > **username_2**: "It works" means "it works in the context of Stockfish evaluation algorithm". That doesn't mean it would work for humans!  
  > **username_3**: The rule of thumb is 3 pawns in a knight/bishop. But that's a simplification. A bishop is almost always worth more than a knight and both pieces are almost always worth more than 3 pawns. That rule works for a simplification, but Stockfish doesn't care for simplifications.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_9 on 2020-05-09. Score: 48 | Accepted answer
  
  I am not an expert on stockfish source code, but my understanding is the following.
  
  Humans:
  
  It is true, that the *1 piece equals 3 pawns approach* is pretty accurate, surprisingly so. However as you are probably aware, when evaluating a position, we consider many other aspects as well, such as piece activity, space, king safety, etc. The difference however is that **we don't assign actual numerical values to these other factors.**
  
  Stockfish (or similar engines):
  
  Unlike humans, engines assign numerical values to all factors. The numbers you mention are just **a small part of the evaluation function.**
  
  Check out the [middlegame evaluation function](https://hxim.github.io/Stockfish-Evaluation-Guide/) for stockfish. On that page you can also modify the board to see the evaluation and you can visit the specific functions such as `piece\_value\_mg' which is concerned with these numbers.
  
  As you can see, just the piece values of all pieces amount to 9326. However there are many other functions which add to the evaluation. Most importantly, **not all of these extra functions treat pawns and pieces equally.**
  
  For instance:
  
  * `Psqt mg', gives values to pawns only, depending on their position on the board. As you would expect, pawns in the center are more valuable (pawn on e4 instead of e2 is +24 points)
  * another pawns only function: `Pawns mg' gives points depending on the pawn structure (isolated, doubled, connected pawns, etc) also here you can gain several tenth of points for the pawns (but not for the pieces).
  
  To be fair, there are also functions that only deal with pieces such as `Pieces mg'. However note that they can also give a penalty (negative value) to the total evaluation. In fact for the starting position you have -63 from that function.
  
  ---
  
  In summary...
  
  Stockfish has a much more fine grained evaluation function than we humans do. The pure piece value from stockfish cannot really be compared with the human piece value.
  
  In stockfish pieces and pawns can gain points in other ways beyond the values you mention. Furthermore, stockfish does not consider the piece on its own, but also how it relates to other pieces, e.g. whether there are doubled pawns, an outpost, etc.
  
  If you check out the code, these other factors are each in the range of several ten points, so if you take them all together you might very well gain the 100 points necessary for the pawn to be 1/3 of a piece.
  
  Mathematically you could also consider it as a kind of approximation or averaging in which you assign a single number (human piece value) for the very complex system that stockfish uses. There is no reason that the average value (human piece value) has any relation to one of the parameters (ValueMG) in the stockfish universe.
  
  I really recommend to see for yourself at the link how much more complete the stockfish evaluation is.
  
  > **Comments:**
  > **username_10**: +1 Excellent answer.  
  
  ---
  
  ### Answer by username_4 on 2020-05-09. Score: 10
  
  Please note that those values are "abstract", later to be modified by the specifics of the position. For example, even though a knight appears 0.8 pawns less valuable than a bishop, it could be that bigger bonuses are awarded to well-placed knights than for well-placed bishops, turning the balance around.
  
  It's also worth noting that the "3 pawns equal a piece" is, for all practical purposes, meaningless. In certain types of positions (those with powerful attacks against the king, for instance), the extra pawns can be useless against a piece. In endgames, three pawns often defeat the piece, specially if not a lot of extra pawns are left
  
  > **Comments:**
  > **username_5**: I think this is the big one: the modifiers to those numbers may be so significant as to render the base numbers kind of meaningless.  
  
  ---
  
  ### Answer by username_6 on 2020-05-09. Score: 7
  
  The value of a piece or pawn will depend greatly upon how well it is placed.  The common 1/3/3.5/5/9 values are reasonable estimates for pieces which are placed decently but not amazingly well.  For various reasons, it may be easier to have the baseline score for a piece represent a piece which is either much worse than typical (so that most pieces would have an adjusted score that was higher), or perhaps have it represent a piece which is much better than typical (so that most pieces would score lower).  As an exaggerated contrived example, consider something like:
  8/p/Pp/RP/1P2nn/RP/P/5K1k w - - 0 1
  
  Even though White nominally has a substantial material advantage (up twice the Exchange, plus three pawns), Black cannot lose without capturing any of the White pawns or pieces.  Although trading a pawn for a rook would normally be a good trade, in this case it is a very bad one since White's pieces are completely useless.  Black will nominally be able to trade a pawn for a rook, which would seem like an advantage, but doing so would enormously increase the value of White's pieces.
  If it is White to mov
  Playing with this example, I think White should be able to eke out a draw, and Black certainly should be able to do at least that.  Playing against Stockfish level 3 on lichess.org, however, I was able to win as both sides because Stockfish overvalued the material at the left and thinks it's worth trading for (I think White should be able to eke out a draw by moving R3-a4, and then a3, but Stockfish didn't find that playing as White, and there might be a way for Black to capture the rook in a situation where Black could then forcce draw by perpetual check/repetition, but Black should have no excuse for losing here.
  Even in less contrived situations, Stockfish sometimes fails to adequately distinguish between pieces which aren't currently in the fray, but are going to get there, versus pieces which can be very cheaply kept out of the action while the opponent has a substantial majority of the immediately-effective material.  A common feature of games between neural networks and Stockfish is that Stockfish ends up letting some of its pieces sit out of the action while the opponent uses its power majority to edge out further advantages, until by the time the blocked-up pieces get to move, the game is already lost.
  Incidentally, I was just playing with another variation on that example (black to play)
  7K/p7/Pp6/RP6/QP4q1/RP3k2/P7/8 b - - 0 1
  
  Black has a mate in four, but Stockfish, even if set for the highest level on lichess.org, will stalemate White via Qg6 rather than achieve victory, probably because any move that continues play with such a large material imbalance is seen as so massively inferior to stalemate that it's not worth investigating further.
  
  > **Comments:**
  > **username_7**: Uh, in that last example, how does black force a win? "move the king to g4", then white replies with Kg1 and it's a draw anyway (e.g. Kg4, Kg1 Kh3, Kh1 g2, Kg1 Kg3)? Stockfish probably goes for the draw because it is a draw, unless I'm missing something?  
  > **username_6**: @username_7: Any idea why Stockfish level 8 on lichess would do Kf1 rather than Kh1 in that line?  
  > **username_6**: @username_7: I think I figured out why Stockfish was never so impertinent as to play Kh1.  Even if Black manages to promote the pawn, White would still be ahead by two rooks and three pawns, so a stalemate would be seen as a bad outcome for White.  
  > **username_6**: @username_7: I reworked the example to show even more clearly that Stockfish is overvaluing pieces that can't move.  Black can immediately achieve a draw, and no position that can be reached within three moves would offer prospects that aren't much worse.  I don't think Stockfish's behavior necessarily represents a "defect", in that improving play in this sort of contrived situation would require spending more time pursuing lines that would be unlikely to be useful outside such contrived situations.  Still interesting, though, that SF would be blind to a mate in four where all of White's moves...  
  > **username_6**: ...are either forced or, in the one case where White would have a choice, the one alternative move would allow immediate mate.  
  > **username_1**: In that last example, my Stockfish finds the mate in less than a second (?)  
  > **username_6**: @username_1: The Stockfish on LiChess has limited configuration options, and its configuration is probably set to just barely prune the key move even on its highest setting.  I wanted to tweak the example to show how far the evaluation could be pushed, but to make it work with other configurations the mate may need to be pushed further out (e.g. perhaps by moving Black's king to c8 instead of c6).  
  
  ---
  
  ### Answer by username_8 on 2020-05-09. Score: 3
  
  I'm afraid it was machine tuned. Nobody knows exactly why. It's like nobody really understand the network weights in LC0. In any case, 3 pawns = a piece is nothing more than a general guidance for chess beginners.
  
  > **Comments:**
  > **username_9**: I think there is more to it (see my too long answer). If a piece was really worth 6 pawns, I doubt stockfish would play as good.  
  
  ---
  
  