user30060: If I understand correctly, Stockfish (15.1 at the time of asking this) values material differently according to the stage of the game, "stages" being analogous to what we call opening, midgame, and endgame.
Is the stage of the game an explicit human-enforced metric, or is it really just a positional awareness from the models in use that people often describe as the stage of the game?
In the case that it is an explicit metric, is this metric a discrete one ("opening", "midgame", etc.), or a continuous one (a number that represents how full the board is)?
I would myself predict that a discrete one would not be used since that would make evaluations based on the future more complicated to get right. For example, you would not want Stockfish to avoid a good move because it turns an opening into a midgame where the measurements of the position are significantly different and result in a (poorly compared) decline in the current position and material score. Even at greater analysis depths, this would be a measurable problem since the transition of stage affects many branches.

user17823: Chess engines use tapered evaluation functions. Stockfish computes the evaluation score for both middlegame and endgame, then interpolates between the two to decide the state the game is in.
More information is available in the Stockfish Evaluation Guide:

Main evaluation
An evaluation function is used to heuristically determine the relative value of a positions used in general case when no specialized evaluation or tablebase evaluation is available. In Stockfish it is never applied for positions where king of either side is in check. Resulting value is computed by combining Middle game evaluation and End game evaluation. We use Tapered Eval, a technique used in evaluation to make a smooth transition between the phases of the game. Phase is a coeficient of simple linear combination. Before using End game evaluation in this formula we also scale it down using Scale factor.

There you can also find a JavaScript implementation of the Stockfish evaluation.

30060: <p>If I understand correctly, Stockfish (15.1 at the time of asking this) values material differently according to the stage of the game, &quot;stages&quot; being analogous to what we call opening, midgame, and endgame.</p>
<p>Is the stage of the game an explicit human-enforced metric, or is it really just a positional awareness from the models in use that people often describe as the stage of the game?</p>
<p>In the case that it is an explicit metric, is this metric a discrete one (&quot;opening&quot;, &quot;midgame&quot;, etc.), or a continuous one (a number that represents how full the board is)?</p>
<p>I would myself predict that a discrete one would not be used since that would make evaluations based on the future more complicated to get right. For example, you would not want Stockfish to avoid a good move because it turns an opening into a midgame where the measurements of the position are significantly different and result in a (poorly compared) decline in the current position and material score. Even at greater analysis depths, this would be a measurable problem since the transition of stage affects many branches.</p>
 17823: <p>Chess engines use <a href="https://www.chessprogramming.org/Tapered_Eval" rel="nofollow noreferrer">tapered evaluation</a> functions. Stockfish computes the evaluation score for both middlegame and endgame, then <a href="https://github.com/official-stockfish/Stockfish/blob/64656f8583dde88d558d5367b4cf8fc136c3214a/src/evaluate.cpp#L950" rel="nofollow noreferrer">interpolates between the two</a> to decide the state the game is in.</p>
<p>More information is available in the <a href="https://hxim.github.io/Stockfish-Evaluation-Guide/" rel="nofollow noreferrer">Stockfish Evaluation Guide</a>:</p>
<blockquote>
<p><strong>Main evaluation</strong><br />
An evaluation function is used to heuristically determine the relative value of a positions used in general case when no specialized evaluation or tablebase evaluation is available. In Stockfish it is never applied for positions where king of either side is in check. Resulting value is computed by combining Middle game evaluation and End game evaluation. We use Tapered Eval, a technique used in evaluation to make a smooth transition between the phases of the game. Phase is a coeficient of simple linear combination. Before using End game evaluation in this formula we also scale it down using Scale factor.</p>
</blockquote>
<p>There you can also find a JavaScript implementation of the Stockfish evaluation.</p>
