Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-30T18:31:51.453Z
Answers.Text: This would be continuous then. And I suppose that whether it was human enforced at some point isn't important because it's been automatically adjusted for best performance.
Answers.UserDisplayName: CubicInfinity
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-29T06:25:02.900Z
Answers.LastActivityDate: 2022-12-29T06:25:02.900Z
Answers.UserDisplayName: double-beep
Body: <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>
  
Tags: <engines><stockfish>
Title: Does Stockfish 15.1 view the stage of the game continuously or discretely, if at all?
ThreadText: # Does Stockfish 15.1 view the stage of the game continuously or discretely, if at all?
  
  (Asked by: username_0 on 2022-12-28)
  
  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.
  
  **Tags:** engines, stockfish
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-29. Score: 3 | Accepted answer
  
  Chess engines use [tapered evaluation](https://www.chessprogramming.org/Tapered_Eval) functions. Stockfish computes the evaluation score for both middlegame and endgame, then [interpolates between the two](https://github.com/official-stockfish/Stockfish/blob/64656f8583dde88d558d5367b4cf8fc136c3214a/src/evaluate.cpp#L950) to decide the state the game is in.
  
  More information is available in the [Stockfish Evaluation Guide](https://hxim.github.io/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.
  
  > **Comments:**
  > **username_0**: This would be continuous then. And I suppose that whether it was human enforced at some point isn't important because it's been automatically adjusted for best performance.  
  
  ---
  
  