## Tapered Eval between 4 phases

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
AndrewGrant
Posts: 494
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

### Tapered Eval between 4 phases

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&#40;queens&#41; * 4
- popcount&#40;rooks&#41; * 2
- popcount&#40;knights | bishops&#41;;
phase = &#40;phase * 256 + 12&#41; / 24;

eval = &#40;mg * &#40;256 - phase&#41; + eg * phase&#41; / 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 = &#40;p1 * &#40;512 - mphase - pphase&#41;)
+ &#40;p2 * &#40;256 - mphase + pphase&#41;)
+ &#40;p3 * &#40;256 + mphase - pphase&#41;)
+ &#40;p4 * (  0 + mphase + pphase&#41;);
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?).

elcabesa
Posts: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

### Re: Tapered Eval between 4 phases

I'd like to try it replacing the number of pawn with open/closed position
But I never tried

hgm
Posts: 23791
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

### Re: Tapered Eval between 4 phases

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: 815
Joined: Sun May 23, 2010 11:32 am
Contact:

### Re: Tapered Eval between 4 phases

My idea is to have a 2 dimension gamephase

jorose
Posts: 269
Joined: Thu Jan 22, 2015 2:21 pm
Location: Zurich, Switzerland
Full name: Jonathan Rosenthal

### Re: Tapered Eval between 4 phases

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.

cdani
Posts: 2104
Joined: Sat Jan 18, 2014 9:24 am
Location: Andorra
Contact:

### Re: Tapered Eval between 4 phases

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.

Evert
Posts: 2924
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

### Re: Tapered Eval between 4 phases

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 9:40 pm
Location: New York

### Re: Tapered Eval between 4 phases

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.