Evaluation¶
Overview¶
The evaluation function returns a score in centipawns from the perspective of the side to move. Positive scores favor the side to move.
Material¶
Piece |
Value (centipawns) |
|---|---|
Pawn |
100 |
Knight |
300 |
Bishop |
350 |
Rook |
500 |
Queen |
1000 |
King |
10000 |
Piece values in Kirin
Positional Factors¶
Piece-Square Tables¶
Each piece type has a positional bonus table. Example for pawns:
const int pawnScore[64] = {
90, 90, 90, 90, 90, 90, 90, 90,
30, 30, 30, 40, 40, 30, 30, 30,
20, 20, 20, 30, 30, 30, 20, 20,
10, 10, 10, 20, 20, 10, 10, 10,
5, 5, 10, 20, 20, 5, 5, 5,
0, 0, 0, 5, 5, 0, 0, 0,
0, 0, 0, -10, -10, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
Knight Positioning¶
Knights are rewarded for central placement:
const int knightScore[64] = {
-5, 0, 0, 0, 0, 0, 0, -5,
-5, 0, 0, 10, 10, 0, 0, -5,
-5, 5, 20, 20, 20, 20, 5, -5,
-5, 10, 20, 30, 30, 20, 10, -5,
-5, 10, 20, 30, 30, 20, 10, -5,
-5, 5, 20, 10, 10, 20, 5, -5,
-5, 0, 0, 0, 0, 0, 0, -5,
-5, -10, 0, 0, 0, 0, -10, -5
};
Pawn Structure¶
Double Pawns¶
Doubled pawns receive a penalty:
const int doublePawnPenalty = -10;
doublePawns = countBits(bitboards[P] & fileMasks[square]);
if(doublePawns > 1) score += doublePawns * doublePawnPenalty;
Isolated Pawns¶
Pawns with no friendly pawns on adjacent files are penalized:
const int isolatedPawnPenalty = -10;
if((bitboards[P] & isolatedMasks[square]) == 0)
score += isolatedPawnPenalty;
Passed Pawns¶
Passed pawns receive bonuses based on how advanced they are:
const int passedPawnBonus[8] = { 0, 10, 30, 50, 75, 100, 150, 200 };
if((passedWhiteMasks[square] & bitboards[p]) == 0)
score += passedPawnBonus[getRank[square]];