Answers.Body: <p>Keep in mind that the <code>phase</code> is supposed to distinguish between middlegame and endgame evals. The larger the value of <code>phase</code>, the more impact it has on determining whether we're at an endgame. Human chess knowledge tells you that the fewer pieces there are on the board, the more endgame-ish the game is. Queens leaving the board has the biggest impact, so queens have the largest phase value. The same goes for rooks, etc.</p>
  <p>Like with many things in handcrafted eval, the exact numbers are empirically tuned.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-29T01:07:26.057Z
Answers.LastActivityDate: 2023-08-29T01:07:26.057Z
Answers.UserDisplayName: Allure
Body: <p>On the chessprogramming wiki site for tapered evaluation, there is the following code snippet for how engines calculate phase:</p>
  <pre><code>eval = ((opening * (256 - phase)) + (endgame * phase)) / 256
  
  PawnPhase = 0
  KnightPhase = 1
  BishopPhase = 1
  RookPhase = 2
  QueenPhase = 4
  TotalPhase = PawnPhase*16 + KnightPhase*4 + BishopPhase*4 + RookPhase*4 + QueenPhase*2
  
  phase = TotalPhase
  
  phase -= wp * PawnPhase // Where wp is the number of white pawns currently on the board
  phase -= wn * Knight    // White knights
  ...
  phase -= br * RookPhase
  phase -= bq * QueenPhase
  
  phase = (phase * 256 + (TotalPhase / 2)) / TotalPhase
  </code></pre>
  <p>I understand most of the phase evaluation function, but my question is, why are piece phase values scored the way they are? I can see how since pawns are technically not pieces, so pawnPhase has a score of 0, but what is the reasoning behind the other phase values?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-29T00:54:52.933Z
Comments.Text: You mean 1, 1, 2, 4?
Comments.UserDisplayName: Allure
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-29T00:59:04.683Z
Comments.Text: @Allure yeah, I want to know the reasoning behind why they chose those numbers
Comments.UserDisplayName: wdk23
Tags: <engines><endgame><programming><evaluation>
Title: How are piece phase values for tapered evaluation/phase calculation calculated?
ThreadText: # How are piece phase values for tapered evaluation/phase calculation calculated?
  
  (Asked by: username_0 on 2023-08-29)
  
  On the chessprogramming wiki site for tapered evaluation, there is the following code snippet for how engines calculate phase:
  
  ```
  eval = ((opening * (256 - phase)) + (endgame * phase)) / 256
  
  PawnPhase = 0
  KnightPhase = 1
  BishopPhase = 1
  RookPhase = 2
  QueenPhase = 4
  TotalPhase = PawnPhase*16 + KnightPhase*4 + BishopPhase*4 + RookPhase*4 + QueenPhase*2
  
  phase = TotalPhase
  
  phase -= wp * PawnPhase // Where wp is the number of white pawns currently on the board
  phase -= wn * Knight    // White knights
  ...
  phase -= br * RookPhase
  phase -= bq * QueenPhase
  
  phase = (phase * 256 + (TotalPhase / 2)) / TotalPhase
  
  ```
  
  I understand most of the phase evaluation function, but my question is, why are piece phase values scored the way they are? I can see how since pawns are technically not pieces, so pawnPhase has a score of 0, but what is the reasoning behind the other phase values?
  
  **Tags:** engines, endgame, programming, evaluation
  
  > **Comments:**
  > **username_1**: You mean 1, 1, 2, 4?  
  > **username_0**: @username_1 yeah, I want to know the reasoning behind why they chose those numbers  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-29. Score: 1 | Accepted answer
  
  Keep in mind that the `phase` is supposed to distinguish between middlegame and endgame evals. The larger the value of `phase`, the more impact it has on determining whether we're at an endgame. Human chess knowledge tells you that the fewer pieces there are on the board, the more endgame-ish the game is. Queens leaving the board has the biggest impact, so queens have the largest phase value. The same goes for rooks, etc.
  
  Like with many things in handcrafted eval, the exact numbers are empirically tuned.
  
  
  ---
  
  