Thanks Harald.Harald wrote: ↑Sat Sep 26, 2020 5:42 pm I dAn't know if you wish to have an evaluation with piece values and PST only or not. I may have missed a part of this thread. However here is my explanation of the tampered evaluation.
For (nearly) all evaluation terms you need two versions of bonusses or penalties. One for the midgame (MG) and one for the endgame (EG). You do not need two versions if the values are the same.
The game phase depends on piece material without pawns but for both players. You can count the pieces (Q, R, B, N, q, r, b, n) and sum them up with weights. The weights may be simple integers like (4, 3, 2, 2, 4, 3, 2, 2) or your normal material values like (1000, 500, 350, 300, 1000, 500, 350, 300). The maximum value of the sum is (36) or (6600) respecively in the opening and (0) in the pawn endgame. From now on I use the 6600 value in my example. Therefore the game phase is (float) piece_material_sum / 6600 between 1.0 and 0.0. In the engine you may want to use an integer value between 1000 and 0.
int game_phase = 1000 * piece_material_sum / 6600; // 1000 in opening/midgame slowly going to 0 in pawn endgame
All evaluation terms are detected once and then summed up in two eval values.
...
value_mg += piece_square_table_mg[K][sq]; // white king midgame
value_eg += piece_square_table_eg[K][sq]; // white king endgame
...
value_mg += num_white_rooks_on_open_files * rook_on_open_file_bonus_mg;
value_eg += num_white_rooks_on_open_files * rook_on_open_file_bonus_eg;
...
And finally at the end of evaluation() there is an interpolation
value = (value_mg * game_phase + value_eg * (1000 - game_phase)) / 1000; // interpolation midgame..endgame and reverse the scaling.
Then comes the normal side and +- score code and the score is returned.
All clear apart from interpolation. I've already read CPW article on it but what my dumb brain still can't get is WHAT IS interpolation.
Here's what clear for me from Ronald's explanations:
So what is called interpolation is something to apply in case if game phase value is between MAXMG and MINEG?PeSTO's interpolation is not between 6.766 and 0, but between MAXMG 6192 and MINEG = 518,
So a phase higher than 6192 uses full MG value, a phase lower than 518 already uses full EG value.
If so I DON'T UNDERSTAND WHICH SCORES (OR HOW THEY ARE CALCULATED) IN THIS CASE?
Do we calculate average score between MG and EG value?
I just stuck and get it AT ALL(((