- #define V(v) Value(v)
- #define S(mg, eg) make_score(mg, eg)
-
- // MobilityBonus[PieceType-2][attacked] contains bonuses for middle and end game,
- // indexed by piece type and number of attacked squares in the mobility area.
- const Score MobilityBonus[][32] = {
- { S(-75,-76), S(-57,-54), S( -9,-28), S( -2,-10), S( 6, 5), S( 14, 12), // Knights
- S( 22, 26), S( 29, 29), S( 36, 29) },
- { S(-48,-59), S(-20,-23), S( 16, -3), S( 26, 13), S( 38, 24), S( 51, 42), // Bishops
- S( 55, 54), S( 63, 57), S( 63, 65), S( 68, 73), S( 81, 78), S( 81, 86),
- S( 91, 88), S( 98, 97) },
- { S(-58,-76), S(-27,-18), S(-15, 28), S(-10, 55), S( -5, 69), S( -2, 82), // Rooks
- S( 9,112), S( 16,118), S( 30,132), S( 29,142), S( 32,155), S( 38,165),
- S( 46,166), S( 48,169), S( 58,171) },
- { S(-39,-36), S(-21,-15), S( 3, 8), S( 3, 18), S( 14, 34), S( 22, 54), // Queens
- S( 28, 61), S( 41, 73), S( 43, 79), S( 48, 92), S( 56, 94), S( 60,104),
- S( 60,113), S( 66,120), S( 67,123), S( 70,126), S( 71,133), S( 73,136),
- S( 79,140), S( 88,143), S( 88,148), S( 99,166), S(102,170), S(102,175),
- S(106,184), S(109,191), S(113,206), S(116,212) }
- };
-
- // Outpost[knight/bishop][supported by pawn] contains bonuses for minor
- // pieces if they can reach an outpost square, bigger if that square is
- // supported by a pawn. If the minor piece occupies an outpost square
- // then score is doubled.
- const Score Outpost[][2] = {
- { S(22, 6), S(36,12) }, // Knight
- { S( 9, 2), S(15, 5) } // Bishop
- };
-
- // RookOnFile[semiopen/open] contains bonuses for each rook when there is no
- // friendly pawn on the rook file.
- const Score RookOnFile[] = { S(20, 7), S(45, 20) };
-
- // ThreatByMinor/ByRook[attacked PieceType] contains bonuses according to
- // which piece type attacks which one. Attacks on lesser pieces which are
- // pawn-defended are not considered.
- const Score ThreatByMinor[PIECE_TYPE_NB] = {
- S(0, 0), S(0, 31), S(39, 42), S(57, 44), S(68, 112), S(47, 120)
- };
-
- const Score ThreatByRook[PIECE_TYPE_NB] = {
- S(0, 0), S(0, 24), S(38, 71), S(38, 61), S(0, 38), S(36, 38)
- };
-
- // ThreatByKing[on one/on many] contains bonuses for king attacks on
- // pawns or pieces which are not pawn-defended.
- const Score ThreatByKing[] = { S(3, 65), S(9, 145) };
-
- // Passed[mg/eg][Rank] contains midgame and endgame bonuses for passed pawns.
- // We don't use a Score because we process the two components independently.
- const Value Passed[][RANK_NB] = {
- { V(0), V(5), V( 5), V(32), V(70), V(172), V(217) },
- { V(0), V(7), V(13), V(42), V(70), V(170), V(269) }
- };
-
- // PassedFile[File] contains a bonus according to the file of a passed pawn
- const Score PassedFile[FILE_NB] = {
- S( 9, 10), S( 2, 10), S( 1, -8), S(-20,-12),
- S(-20,-12), S( 1, -8), S( 2, 10), S( 9, 10)
- };
-
- // Rank factor applied on some bonus for passed pawn on rank 4 or beyond
- const int RankFactor[RANK_NB] = {0, 0, 0, 2, 7, 12, 19};
-
- // KingProtector[PieceType-2] contains a bonus according to distance from king
- const Score KingProtector[] = { S(-3, -5), S(-4, -3), S(-3, 0), S(-1, 1) };
-
- // Assorted bonuses and penalties used by evaluation
- const Score MinorBehindPawn = S( 16, 0);
- const Score BishopPawns = S( 8, 12);
- const Score LongRangedBishop = S( 22, 0);
- const Score RookOnPawn = S( 8, 24);
- const Score TrappedRook = S( 92, 0);
- const Score WeakQueen = S( 50, 10);
- const Score CloseEnemies = S( 7, 0);
- const Score PawnlessFlank = S( 20, 80);
- const Score ThreatBySafePawn = S(175,168);
- const Score ThreatByRank = S( 16, 3);
- const Score Hanging = S( 52, 30);
- const Score WeakUnopposedPawn = S( 5, 25);
- const Score ThreatByPawnPush = S( 47, 26);
- const Score ThreatByAttackOnQueen = S( 42, 21);
- const Score HinderPassedPawn = S( 8, 1);
- const Score TrappedBishopA1H1 = S( 50, 50);
-
- #undef S
- #undef V
-
- // KingAttackWeights[PieceType] contains king attack weights by piece type
- const int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 78, 56, 45, 11 };
-
- // Penalties for enemy's safe checks
- const int QueenSafeCheck = 780;
- const int RookSafeCheck = 880;
- const int BishopSafeCheck = 435;
- const int KnightSafeCheck = 790;
-
- // Threshold for lazy and space evaluation
- const Value LazyThreshold = Value(1500);
- const Value SpaceThreshold = Value(12222);
-
-
- // initialize() computes king and pawn attacks, and the king ring bitboard
- // for a given color. This is done at the beginning of the evaluation.