I've been going through some code using the PeSTO evaluation function, but I program in JavaScript so not quite sure what is going on in some of the code. I'm hoping I can get some help here. I understand some of it, but parts I'm stuck on, so I will ask questions based on those elements.
This is the page I have been viewing: https://www.chessprogramming.org/PeSTO% ... n_Function
I think I understand that for say a pawn, you take its position on the board, lookup the mg_pawn_table and add it to the mg_value of 82. So, if the pawn was on d4, it would be 12 + 81 = 93 or 0.93 pawns in the middlegame.
But then we get to this:
Code: Select all
int gamephaseInc[12] = {0,0,1,1,1,1,2,2,4,4,0,0};I am also a bit confused on what this does too:
Code: Select all
/* evaluate each piece */
for (int sq = 0; sq < 64; ++sq) {
int pc = board[sq];
if (pc != EMPTY) {
mg[PCOLOR(pc)] += mg_table[pc][sq];
eg[PCOLOR(pc)] += eg_table[pc][sq];
gamePhase += gamephaseInc[pc];
}
}
/* tapered eval */
int mgScore = mg[side2move] - mg[OTHER(side2move)];
int egScore = eg[side2move] - eg[OTHER(side2move)];
int mgPhase = gamePhase;
if (mgPhase > 24) mgPhase = 24; /* in case of early promotion */
int egPhase = 24 - mgPhase;
return (mgScore * mgPhase + egScore * egPhase) / 24;Thanks.


