Tapered Eval between 4 phases

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Tapered Eval between 4 phases

Post by AndrewGrant »

So I (and I think most of us) are using some variant of shifting evaluation between MG and EG based on material values.

Code: Select all

    phase = 24 - popcount(queens) * 4
               - popcount(rooks) * 2
               - popcount(knights | bishops);
    phase = (phase * 256 + 12) / 24;
          
    eval = (mg * (256 - phase) + eg * phase) / 256;
I'm getting ready to try something a bit different. Instead of MG and EG, we have four different phases

Each type of Phase
P1 = All Pawns & All Minor/Major
P2 = All Pawns & No Minor/Major
P3 = No Pawns & All Minor/Major
P4 = No Pawns & No Minor/Major

We will say mphase (Minor/Major Phase) = the same as the phase in the above code snipet.
We will say pphase (Pawn Phase) = ((16 - popcount(pawns)) * 256 + 8) / 16

Then to compute the actual evaluation, based on the P1, P2, P3 and P4 evaluations we will say

Code: Select all

eval = (p1 * (512 - mphase - pphase))
     + (p2 * (256 - mphase + pphase))
     + (p3 * (256 + mphase - pphase))
     + (p4 * (  0 + mphase + pphase));
eval = eval / 1024;
Has anyone tried anything along these lines? I only know of one engine that uses a 3 phased evaluation (Gull? or Fire?).
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Tapered Eval between 4 phases

Post by elcabesa »

I'd like to try it replacing the number of pawn with open/closed position
But I never tried
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Tapered Eval between 4 phases

Post by hgm »

IMO the largest shortcoming of the two-phase model is not the shape of the interpolation, but that all eval parameters depend on the same game-phase variable. I other words, that game phase is a one-dimensional quantity. It is very unlikely that King safety should be interpolated the same way between a full FIDE setup and bare Kings as, for instance, the value of pushing passers.

In other words, worrying about the number of intermediate phases is a lot like worrying about the exact radius a circle has to have to best approximate a given square.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Tapered Eval between 4 phases

Post by elcabesa »

My idea is to have a 2 dimension gamephase
jorose
Posts: 358
Joined: Thu Jan 22, 2015 3:21 pm
Location: Zurich, Switzerland
Full name: Jonathan Rosenthal

Re: Tapered Eval between 4 phases

Post by jorose »

I use a generalization of this in Winter. I assume every position is from some set of k Gaussians. For every position evaluation I estimate the probability that a position is from each of those Gaussians and interpolate the evaluation based on the parameters I estimated for each Gaussian and these probabilities.

Unfortunately Winter is still very weak relative to top engines, so I don't feel confident the idea is worth anything in general, but for Winter it seems to be working quite well.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Tapered Eval between 4 phases

Post by cdani »

In Andscacs I have various bonus/penalizations related to the number of pawns and closed center. I think is better to have specific features like this than generic ones, as Hgm suggest. Anyway I have also an standard two phase tapered eval.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Tapered Eval between 4 phases

Post by Evert »

hgm wrote:IMO the largest shortcoming of the two-phase model is not the shape of the interpolation, but that all eval parameters depend on the same game-phase variable. I other words, that game phase is a one-dimensional quantity. It is very unlikely that King safety should be interpolated the same way between a full FIDE setup and bare Kings as, for instance, the value of pushing passers.
Yes.
I usually divide phases as "hide king", "activate king" and "run with pawns", at least in my mind. No, for orthochess, "activate king" and "run with pawns" are close enough that you can lump them together, so you end up with two phases you could label "middle game" and "end game" if you like.
For variants it is a different matter, of course.
ymatioun
Posts: 64
Joined: Fri Oct 18, 2013 11:40 pm
Location: New York

Re: Tapered Eval between 4 phases

Post by ymatioun »

I tried this earlier this year; i tried using 4 stages, 8 stages and even 16 stages (you can fit 16 16-bit values into one AVX variable that you can operate on in one instruction, so up to 16 stages can be accommodated with virtually no performance penalty). This significantly reduces variance of the residual in optimization(possibly due to overfitting), but i could not get any performance improvement.