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;
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;

