Answers.Body: <p>I think you don't need this. You shift from opening to middle game when your opening book for this line runs out.
  The middle-end phase is less relevant in AI, and your algorithm will handle those the same. You could define a line, e.g. when your search depth could be increased over some threshold, because the board has only a handful of pieces left, but I don't think it's an important change.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T15:25:06.137Z
Answers.Text: Okay, I see what you're saying, however, I think the king's role changes in the endgame enough to warrant this, if nothing else. I am not extremely well versed in chess theory but I know it is important to activate the king in the endgame, rather than hide it away, protected like the middlegame. Thoughts?
Answers.UserDisplayName: Damion Lance
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T15:43:06.623Z
Answers.Text: I know from experience you need 2 nights to implement Minimax with alpha-beta pruning for a simple game (Chess might be a bit more tedious to code than Reversi I've did, so maybe add 1 more night). Then you'll see it for yourself. Even an AI just doing that will beat an average player on contemporary hardware. Your AI will know from looking ahead 10-15 moves that moving your king into the center is bad for the middle game and good in the end when mostly pawns are around.
Answers.UserDisplayName: Nyos
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T08:46:17.213Z
Answers.LastActivityDate: 2019-12-09T08:46:17.213Z
Answers.UserDisplayName: Nyos
Answers.Body: <p>There is no sharp definition that would say x moves and y moves is where.</p>
  
  <p>The opening is pretty much over when you have exhausted moves that have been played so many times by many players. It could be short if someone makes an unusual move, or, for a very long time, play some extremely old lines especially when GMs want to play safe for a draw.  </p>
  
  <p>Endgames would tend to start when there is really not enough material to mount a mating attack by force.  Just trading queens is not enough if all the other pieces are still in play.  </p>
  
  <p>But none of this should matter to an AI program.  They are just arbitrary identifiers to help indicate the stage of the game. </p>
  
  <p>A good AI program would evaluate the position independently of what stage you thought the game was in.  Not doing so would lead to a number of places that give weird results.  Anyway, isn't AI supposed to determine those weightings for itself based on the position?</p>
  
  <p>The problem is you can't train AI with enough examples to really make AI work the way it normally does.  </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T05:42:13.270Z
Answers.Text: I see what you're saying however, in reference to your last statements, I'm not using a data-driven AI, but an expert-based, rule driven agent. This way it will not "learn" best moves based on neural networks or other machine learning algorithms, but rather with rules and heuristics.
Answers.UserDisplayName: Damion Lance
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T14:02:22.610Z
Answers.Text: @DamionLance -  Then we disagree on what AI really is.  I do not call rule based decision AI but merely a fancy program to make decisions.  I may be too old , but I do not see how it learns anything from rules and heuristics.  Are you using a sort of genetic algorithm to adjust the rules?  Then again I do not think you can have enough data to do that.  Maybe for an opening but not later on.
Answers.UserDisplayName: yobamamama
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T14:04:53.387Z
Answers.Text: @DamionLance  -  What school is this?  HS like a science fair project,  special 'governors' school for the super smart,  community college, university, graduate school?   I would suggest especially for earlier on that scale you try to find a way to scale the problem down.
Answers.UserDisplayName: yobamamama
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T15:16:37.557Z
Answers.Text: This is for an undergraduate project for my 300's level intelligent systems course. Basically the way it operates is the agent evaluates all possible moves and decides which ones are useful (based on positional heuristics and potential for capture or mate), then uses a minimax algorithm to find which moves maximize gain for itself, while minimizing board value for the opponent.
Answers.UserDisplayName: Damion Lance
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T18:28:18.747Z
Answers.Text: @DamionLance  -  that sounds reasonable for that course.  I think you need a different set of rules to evaluate the end of the initial tree analysis.  More based on pawn structure, material, positional factors, then those could work for any phase of the game.  Openings should be by history of results from GM games to simplify the task.
Answers.UserDisplayName: yobamamama
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-09T01:16:31.043Z
Answers.LastActivityDate: 2019-12-11T01:17:09.193Z
Answers.LastEditDate: 2019-12-11T01:17:09.193Z
Answers.UserDisplayName: yobamamama
Answers.Body: <p>As a rough estimate, I've once seen the definition that the endgames begins when each side's pieces has a strength of 13 or less (counting 9 for queen, 5 for rook, 3 for bishop/knight and ignoring pawns) Can't remember the source, though.</p>
  
  <p>The opening is often said to end when all of the pieces are developped, but it's not always so clear. You may want to alow one piece to stay on its starting square and call it the middlegame already</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-12T12:16:06.810Z
Answers.LastActivityDate: 2019-12-12T12:16:06.810Z
Answers.UserDisplayName: David
Body: <p>I'm working on a chess AI for a school project and I am looking into ways to identify the current phase of a board, meaning the opening, middlegame, and  endgame. I have seen an article explaining <a href="https://www.chessprogramming.org/Tapered_Eval" rel="noreferrer">Tapered Evaluation</a>, however I don't really understand what the point of this is. I want to be able to change my overall board evaluation heuristic depending on what state the game is in. This way, in the middlegame, I can prioritize king protection and development and other strategies.</p>
  
Tags: <engines><programming><evaluation>
Title: Help with game phase identification
ThreadText: # Help with game phase identification
  
  (Asked by: username_0 on 2019-12-08)
  
  I'm working on a chess AI for a school project and I am looking into ways to identify the current phase of a board, meaning the opening, middlegame, and endgame. I have seen an article explaining [Tapered Evaluation](https://www.chessprogramming.org/Tapered_Eval), however I don't really understand what the point of this is. I want to be able to change my overall board evaluation heuristic depending on what state the game is in. This way, in the middlegame, I can prioritize king protection and development and other strategies.
  
  **Tags:** engines, programming, evaluation
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2019-12-09. Score: 6
  
  I think you don't need this. You shift from opening to middle game when your opening book for this line runs out.
  The middle-end phase is less relevant in AI, and your algorithm will handle those the same. You could define a line, e.g. when your search depth could be increased over some threshold, because the board has only a handful of pieces left, but I don't think it's an important change.
  
  > **Comments:**
  > **username_0**: Okay, I see what you're saying, however, I think the king's role changes in the endgame enough to warrant this, if nothing else. I am not extremely well versed in chess theory but I know it is important to activate the king in the endgame, rather than hide it away, protected like the middlegame. Thoughts?  
  > **username_1**: I know from experience you need 2 nights to implement Minimax with alpha-beta pruning for a simple game (Chess might be a bit more tedious to code than Reversi I've did, so maybe add 1 more night). Then you'll see it for yourself. Even an AI just doing that will beat an average player on contemporary hardware. Your AI will know from looking ahead 10-15 moves that moving your king into the center is bad for the middle game and good in the end when mostly pawns are around.  
  
  ---
  
  ### Answer by username_2 on 2019-12-09. Score: 2
  
  There is no sharp definition that would say x moves and y moves is where.
  
  The opening is pretty much over when you have exhausted moves that have been played so many times by many players. It could be short if someone makes an unusual move, or, for a very long time, play some extremely old lines especially when GMs want to play safe for a draw.
  
  Endgames would tend to start when there is really not enough material to mount a mating attack by force. Just trading queens is not enough if all the other pieces are still in play.
  
  But none of this should matter to an AI program. They are just arbitrary identifiers to help indicate the stage of the game.
  
  A good AI program would evaluate the position independently of what stage you thought the game was in. Not doing so would lead to a number of places that give weird results. Anyway, isn't AI supposed to determine those weightings for itself based on the position?
  
  The problem is you can't train AI with enough examples to really make AI work the way it normally does.
  
  > **Comments:**
  > **username_0**: I see what you're saying however, in reference to your last statements, I'm not using a data-driven AI, but an expert-based, rule driven agent. This way it will not "learn" best moves based on neural networks or other machine learning algorithms, but rather with rules and heuristics.  
  > **username_2**: @DamionLance -  Then we disagree on what AI really is.  I do not call rule based decision AI but merely a fancy program to make decisions.  I may be too old , but I do not see how it learns anything from rules and heuristics.  Are you using a sort of genetic algorithm to adjust the rules?  Then again I do not think you can have enough data to do that.  Maybe for an opening but not later on.  
  > **username_2**: @DamionLance  -  What school is this?  HS like a science fair project,  special 'governors' school for the super smart,  community college, university, graduate school?   I would suggest especially for earlier on that scale you try to find a way to scale the problem down.  
  > **username_0**: This is for an undergraduate project for my 300's level intelligent systems course. Basically the way it operates is the agent evaluates all possible moves and decides which ones are useful (based on positional heuristics and potential for capture or mate), then uses a minimax algorithm to find which moves maximize gain for itself, while minimizing board value for the opponent.  
  > **username_2**: @DamionLance  -  that sounds reasonable for that course.  I think you need a different set of rules to evaluate the end of the initial tree analysis.  More based on pawn structure, material, positional factors, then those could work for any phase of the game.  Openings should be by history of results from GM games to simplify the task.  
  
  ---
  
  ### Answer by username_3 on 2019-12-12. Score: 1
  
  As a rough estimate, I've once seen the definition that the endgames begins when each side's pieces has a strength of 13 or less (counting 9 for queen, 5 for rook, 3 for bishop/knight and ignoring pawns) Can't remember the source, though.
  
  The opening is often said to end when all of the pieces are developped, but it's not always so clear. You may want to alow one piece to stay on its starting square and call it the middlegame already
  
  
  ---
  
  