Stockfish eval output

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Stockfish eval output

Post by zenpawn »

In the following technically drawn ending, it's no surprise Stockfish recognizes the situation without need of a search or EGT. The static eval gives white a symbolic edge of 0.08. Unfortunately, the pretty output doesn't show what it's using to offset the material difference, even if that's just a line for Known Draw. Not sure there's a question here, just an observation.

[d]k7/P7/3K4/8/8/4B3/8/8 w - - 0 1

Code: Select all

position fen k7/P7/3K4/8/8/4B3/8/8 w - - 0 1
eval
      Eval term |    White    |    Black    |    Total
                |   MG    EG  |   MG    EG  |   MG    EG
----------------+-------------+-------------+-------------
       Material |   ---   --- |   ---   --- |  3.11  5.01
      Imbalance |   ---   --- |   ---   --- | -0.05 -0.05
          Pawns |   ---   --- |   ---   --- | -0.12 -0.14
        Knights |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Bishop |  0.00 -0.04 |  0.00  0.00 |  0.00 -0.04
          Rooks |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Queens |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
       Mobility |  0.31  0.29 |  0.00  0.00 |  0.31  0.29
    King safety |  0.00 -0.19 |  0.86  0.00 | -0.86 -0.19
        Threats |  0.00  0.00 |  0.01  0.24 | -0.01 -0.24
   Passed pawns |  0.99  0.31 |  0.00  0.00 |  0.99  0.31
          Space |  0.01  0.00 |  0.00  0.00 |  0.01  0.00
----------------+-------------+-------------+-------------
          Total |   ---   --- |   ---   --- |  3.36  4.64

Total Evaluation: 0.08 (white side)
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish eval output

Post by Sven »

zenpawn wrote:In the following technically drawn ending, it's no surprise Stockfish recognizes the situation without need of a search or EGT. The static eval gives white a symbolic edge of 0.08. Unfortunately, the pretty output doesn't show what it's using to offset the material difference, even if that's just a line for Known Draw. Not sure there's a question here, just an observation.

[d]k7/P7/3K4/8/8/4B3/8/8 w - - 0 1

Code: Select all

position fen k7/P7/3K4/8/8/4B3/8/8 w - - 0 1
eval
      Eval term |    White    |    Black    |    Total
                |   MG    EG  |   MG    EG  |   MG    EG
----------------+-------------+-------------+-------------
       Material |   ---   --- |   ---   --- |  3.11  5.01
      Imbalance |   ---   --- |   ---   --- | -0.05 -0.05
          Pawns |   ---   --- |   ---   --- | -0.12 -0.14
        Knights |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Bishop |  0.00 -0.04 |  0.00  0.00 |  0.00 -0.04
          Rooks |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Queens |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
       Mobility |  0.31  0.29 |  0.00  0.00 |  0.31  0.29
    King safety |  0.00 -0.19 |  0.86  0.00 | -0.86 -0.19
        Threats |  0.00  0.00 |  0.01  0.24 | -0.01 -0.24
   Passed pawns |  0.99  0.31 |  0.00  0.00 |  0.99  0.31
          Space |  0.01  0.00 |  0.00  0.00 |  0.01  0.00
----------------+-------------+-------------+-------------
          Total |   ---   --- |   ---   --- |  3.36  4.64

Total Evaluation: 0.08 (white side)
Stockfish detects this wrong-colored bishop endgame and therefore scales the evaluation down close to zero. But the table above does not contain the scaling factor that may have been found. The final score is not exactly zero because (as I understand it) the scaling factor is applied to the endgame component of the score while the middlegame component remains unscaled. Since the position has almost no pieces the endgame term is dominating but the middlegame term still has a very small influence.
zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Re: Stockfish eval output

Post by zenpawn »

Yeah, guess I was just hoping for it to have a line in the table. Still a nice display nonetheless.

On the topic of static evals, is there a way/program to run through a PGN to get the evaluations of the positions along the way without the engine doing any search? I came close by setting Fritz 15 to perform its blunder check with depth 1 and margin (to consider a move a blunder) of 0.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Stockfish eval output

Post by Joerg Oster »

Sven Schüle wrote:
zenpawn wrote:In the following technically drawn ending, it's no surprise Stockfish recognizes the situation without need of a search or EGT. The static eval gives white a symbolic edge of 0.08. Unfortunately, the pretty output doesn't show what it's using to offset the material difference, even if that's just a line for Known Draw. Not sure there's a question here, just an observation.

[d]k7/P7/3K4/8/8/4B3/8/8 w - - 0 1

Code: Select all

position fen k7/P7/3K4/8/8/4B3/8/8 w - - 0 1
eval
      Eval term |    White    |    Black    |    Total
                |   MG    EG  |   MG    EG  |   MG    EG
----------------+-------------+-------------+-------------
       Material |   ---   --- |   ---   --- |  3.11  5.01
      Imbalance |   ---   --- |   ---   --- | -0.05 -0.05
          Pawns |   ---   --- |   ---   --- | -0.12 -0.14
        Knights |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Bishop |  0.00 -0.04 |  0.00  0.00 |  0.00 -0.04
          Rooks |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Queens |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
       Mobility |  0.31  0.29 |  0.00  0.00 |  0.31  0.29
    King safety |  0.00 -0.19 |  0.86  0.00 | -0.86 -0.19
        Threats |  0.00  0.00 |  0.01  0.24 | -0.01 -0.24
   Passed pawns |  0.99  0.31 |  0.00  0.00 |  0.99  0.31
          Space |  0.01  0.00 |  0.00  0.00 |  0.01  0.00
----------------+-------------+-------------+-------------
          Total |   ---   --- |   ---   --- |  3.36  4.64

Total Evaluation: 0.08 (white side)
Stockfish detects this wrong-colored bishop endgame and therefore scales the evaluation down close to zero. But the table above does not contain the scaling factor that may have been found. The final score is not exactly zero because (as I understand it) the scaling factor is applied to the endgame component of the score while the middlegame component remains unscaled. Since the position has almost no pieces the endgame term is dominating but the middlegame term still has a very small influence.
No, it's the tempo bonus added for the side to move. :)

Code: Select all

  return (pos.side_to_move() == WHITE ? v : -v) + Eval::Tempo; // Side to move point of view
But it would be nice if the scaling factor would be displayed, as well.
Jörg Oster
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish eval output

Post by Sven »

Joerg Oster wrote:
Sven Schüle wrote:The final score is not exactly zero because (as I understand it) the scaling factor is applied to the endgame component of the score while the middlegame component remains unscaled. Since the position has almost no pieces the endgame term is dominating but the middlegame term still has a very small influence.
No, it's the tempo bonus added for the side to move. :)

Code: Select all

  return (pos.side_to_move() == WHITE ? v : -v) + Eval::Tempo; // Side to move point of view
But the tempo bonus is currently 20, not 8 ... and it was 17 in Stockfish 7.
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Stockfish eval output

Post by Joerg Oster »

Sven Schüle wrote:
Joerg Oster wrote:
Sven Schüle wrote:The final score is not exactly zero because (as I understand it) the scaling factor is applied to the endgame component of the score while the middlegame component remains unscaled. Since the position has almost no pieces the endgame term is dominating but the middlegame term still has a very small influence.
No, it's the tempo bonus added for the side to move. :)

Code: Select all

  return (pos.side_to_move() == WHITE ? v : -v) + Eval::Tempo; // Side to move point of view
But the tempo bonus is currently 20, not 8 ... and it was 17 in Stockfish 7.
But that's the internal value, not centipawns.
The internal value is finally scaled to cp for output with:
https://github.com/official-stockfish/S ... #L228-L238
Jörg Oster
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish eval output

Post by Sven »

Joerg Oster wrote:
Sven Schüle wrote:
Joerg Oster wrote:
Sven Schüle wrote:The final score is not exactly zero because (as I understand it) the scaling factor is applied to the endgame component of the score while the middlegame component remains unscaled. Since the position has almost no pieces the endgame term is dominating but the middlegame term still has a very small influence.
No, it's the tempo bonus added for the side to move. :)

Code: Select all

  return (pos.side_to_move() == WHITE ? v : -v) + Eval::Tempo; // Side to move point of view
But the tempo bonus is currently 20, not 8 ... and it was 17 in Stockfish 7.
But that's the internal value, not centipawns.
The internal value is finally scaled to cp for output with:
https://github.com/official-stockfish/S ... #L228-L238
Ok, I see you are right, I forgot that the internal SF scoring is not in centipawns. (Note: it is not in uci.cpp but in evaluate.cpp where the table above is printed within do_trace() - called when the user types the "eval" command - using the function to_cp() for the total score, but the principle is the same.)

So the scaling of the score without the tempo bonus seems to result in an internal score of at most 3, since otherwise rounding of (20 + 4) / 258 = 0.093.... would have printed 0.09 (the code for printing the eval table uses setprecision(2) which does not round as far as I know). I did not check that since it is not directly related to the original topic of this thread which is now solved ...

Nevertheless, I'd still propose to extend the table output by adding both the scaling factor and the tempo bonus, for completeness.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish eval output

Post by Sven »

Sven Schüle wrote:So the scaling of the score without the tempo bonus seems to result in an internal score of at most 3, since otherwise rounding of (20 + 4) / 258 = 0.093.... would have printed 0.09 (the code for printing the eval table uses setprecision(2) which does not round as far as I know). I did not check that since it is not directly related to the original topic of this thread which is now solved ...
To close this last topic as well: in the given position the game_phase is 0 since the value of the non-pawn material (only one white bishop) is less than the constant "EndgameLimit". Therefore the middlegame part of the score actually has zero influence in this case, as in all endgames with few non-pawn pieces. E.g. QR or Q vs. R is below that limit while Q vs. BN is above it.
zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Re: Stockfish eval output

Post by zenpawn »

Just came across a reverse case, i.e., no material score (nor any other, for that matter), yet a big final eval.

[d]8/3Q4/3K1k2/8/8/8/8/7r b - - 0 1

Code: Select all

position fen 8/3Q4/3K1k2/8/8/8/8/7r b - - 0 1
eval
      Eval term |    White    |    Black    |    Total
                |   MG    EG  |   MG    EG  |   MG    EG
----------------+-------------+-------------+-------------
       Material |   ---   --- |   ---   --- |  0.00  0.00
      Imbalance |   ---   --- |   ---   --- |  0.00  0.00
          Pawns |   ---   --- |   ---   --- |  0.00  0.00
        Knights |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Bishop |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
          Rooks |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Queens |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
       Mobility |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
    King safety |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
        Threats |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
   Passed pawns |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
          Space |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
----------------+-------------+-------------+-------------
          Total |   ---   --- |   ---   --- |  0.00  0.00

Total Evaluation: 5.72 (white side)
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish eval output

Post by Sven »

zenpawn wrote:Just came across a reverse case, i.e., no material score (nor any other, for that matter), yet a big final eval.

[d]8/3Q4/3K1k2/8/8/8/8/7r b - - 0 1

Code: Select all

position fen 8/3Q4/3K1k2/8/8/8/8/7r b - - 0 1
eval
      Eval term |    White    |    Black    |    Total
                |   MG    EG  |   MG    EG  |   MG    EG
----------------+-------------+-------------+-------------
       Material |   ---   --- |   ---   --- |  0.00  0.00
      Imbalance |   ---   --- |   ---   --- |  0.00  0.00
          Pawns |   ---   --- |   ---   --- |  0.00  0.00
        Knights |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Bishop |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
          Rooks |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
         Queens |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
       Mobility |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
    King safety |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
        Threats |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
   Passed pawns |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
          Space |  0.00  0.00 |  0.00  0.00 |  0.00  0.00
----------------+-------------+-------------+-------------
          Total |   ---   --- |   ---   --- |  0.00  0.00

Total Evaluation: 5.72 (white side)
KQkr is one of the endgames that have their own special evaluation functions in endgame.cpp. As you point out, these special endgame scores are not covered by the "eval" command output so far.