Game Phase and tapered PSQT evaluation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
emadsen
Posts: 434
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Game Phase and tapered PSQT evaluation

Post by emadsen »

hgm wrote: Thu Jun 24, 2021 9:35 am I thought Fruit used 0,1,1,3,6, to make them add up to a power of 2 (namely 32), so that the division by the total is just a right-shift.
Fruit uses 1, 1, 2, 4 according to this source code.
My C# chess engine: https://www.madchess.net
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Game Phase and tapered PSQT evaluation

Post by hgm »

You are right! I wonder where I have seen the 1, 1, 3, 6, then. I didn't study sources of that many engines.
User avatar
emadsen
Posts: 434
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Game Phase and tapered PSQT evaluation

Post by emadsen »

hgm wrote: Thu Jun 24, 2021 5:10 pm You are right! I wonder where I have seen the 1, 1, 3, 6, then. I didn't study sources of that many engines.
I'm pretty sure I came up with 10, 10, 22, 44 weights on my own. I wanted something that representing a doubling of importance in the progression minor > rook > queen and allowed a bit-shift for division. Only afterwards noticed it was approximately equivalent to Fruit's weights.

1, 1, 3, 6 is an interesting idea though. Probably worth testing. My hunch is it's ELO-neutral. Probably just forces a re-tuning of all eval params to reflect a heavier bias towards endgame values.
My C# chess engine: https://www.madchess.net
Jon12345
Posts: 80
Joined: Tue May 11, 2010 6:18 pm

Re: Game Phase and tapered PSQT evaluation

Post by Jon12345 »

Hey, some great replies there. Big thanks for that. It makes much more sense to me now. Just got to get down to doing the coding now.

I've got a question and I know the answer is a little bit arbitrary, but using the 24 to 0 tapering system from the PeSTO evaluation function, what value do you think constitutes the start of the middlegame, and what value for the endgame?
Jon
User avatar
emadsen
Posts: 434
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Game Phase and tapered PSQT evaluation

Post by emadsen »

Jon12345 wrote: Thu Jun 24, 2021 10:02 pmusing the 24 to 0 tapering system from the PeSTO evaluation function, what value do you think constitutes the start of the middlegame, and what value for the endgame?
MG = 24, EG = 0

I think you're missing the point. Using 1, 1, 2, 4 weights (for N, B, R, Q), phase = 24 at start of game = 100% MG = 0% EG. When all pieces have been captured (leaving only pawns and kings), phase = 0 = 0% MG = 100% EG. During the game, for example, after an exchange of three minors and one rook, phase = 24 - (6 * 1) - (2 * 2) = 14 = 58% MG = 42% EG.

Perhaps you're confused because you're assuming scoring transitions from an opening phase to a middlegame phase to an endgame phase. That's not how it works. Tapered evaluation is confined to MG and EG- that's it. The game begins 100% MG and transitions towards 0% MG. Unless the game ends as a king and pawn draw, it will never reach 0% MG. The percentages simply tell you how to weight eval params when calculating a static score for a position.

Alternative systems transition from MG = 32 to EG = 0. Or MG = 256 to EG = 0. Depends how you weight each piece.
My C# chess engine: https://www.madchess.net
Jon12345
Posts: 80
Joined: Tue May 11, 2010 6:18 pm

Re: Game Phase and tapered PSQT evaluation

Post by Jon12345 »

I fully understood how it works, based on the previous explanations given.

If you look at sites like lichess, they have the Computer analysis graph where they state where the middlegame and endgame starts. I want to do the same. That is why I said when it starts and ends is arbitrary. However, I wanted to get a feel for what people here considered the start and end of the middlegame, to reduce my own personal bias.
Jon