Early / middle / end game transitions?

Code, algorithms, languages, construction...
Post Reply
notachessplayer
Posts: 30
Joined: Thu Dec 29, 2016 10:13 pm

Early / middle / end game transitions?

Post by notachessplayer » Sun Feb 19, 2017 3:24 am

I've been reading books about chess strategy to be able to code my AI properly, but the limit is never clear.
I was wondering what is generally a good time to change the state of the game to middle or end game, in chess programming?
What do stockfish, komodo, houdini do?

thevinenator
Posts: 68
Joined: Tue Jun 02, 2015 11:02 pm
Real Name: Vince

Re: Early / middle / end game transitions?

Post by thevinenator » Sun Feb 19, 2017 4:41 pm

notachessplayer wrote:I've been reading books about chess strategy to be able to code my AI properly, but the limit is never clear.
I was wondering what is generally a good time to change the state of the game to middle or end game, in chess programming?
What do stockfish, komodo, houdini do?
When you find out the best way to do it, please share! LOL

this is one of those, "there is no right way" topics.
there are many ways to look at it. i have special code for all 2-3-4 piece endings, so my eval jumps to those whenever detected. I've been reading up on pawn only endings, so perhaps at some point i'll have "ending" code to deal with pawn only. does that mean my "endgame" starts then? not really.

it all depends what you are going to do once you have detected your "endgame". there are examples, such as the test in NULL move that says, if in endgame, don't do NULL move, but you'll have to play around to decide what you like best. one can always find zugzwang positions that will make every endgame cutoff fail. no holy grail here. what defines endgame for NULL move might be wrong elsewhere.

SF does a lot of eval tapering, meaning the score of an eval element changes between the beginning and ending of the game. you could look at it from that perspective on a case by case basis.
"An Engine's strength flows from the Search. But beware, pruning, extensions, reductions; the dark side of the Search are they. Once you start down the dark path, it will dominate and consume you, as it has to so many developers before.” -- Yoda

H.G.Muller
Posts: 190
Joined: Sun Jul 14, 2013 10:00 am
Real Name: H.G. Muller

Re: Early / middle / end game transitions?

Post by H.G.Muller » Sun Feb 19, 2017 6:43 pm

Most engines do not define a point of sudden transition between the game phases, but calculate an 'opening' and 'end-game' score (using different piece values, piece-square tables, king-safety weights,mobility weights, and interpolate these linearly depending on the value of the material still on the board. The latter is usually calculated without paying attention to Pawns, e.g. Q=6, R=3, N=B=1, P=0. Then the game phase can range from 32 (100% opening, 0% end-game) to 0 (0% opening, 100% end-game).

For specific late end-games there can be special evaluation functions. These are usually recognized by keeping track of a 'material index', mapping every material combination to a unique number,and using that to access a table. Such a table could contain a simple additive score corrections (e.g. to account for the Bishop pairs), a multiplication factor for drawishness (e.g. when there are no Pawns, or the last Pawn can be sacrificed away leaving a dawnless draw),or the numberof a specilized end-game evaluator that also takes the location of the pieces into account (e.g. KPK, KBPK, KQKP). These can even be in an exhaustive table, or a much smaller material hash table.

Post Reply