- // Increase bonus if supported by pawn, especially if the opponent has
- // no minor piece which can exchange the outpost piece
- if (v && (p.pawn_attacks(them, s) & p.pawns(us)))
- {
- bonus += v / 2;
- if ( p.piece_count(them, KNIGHT) == 0
- && (SquaresByColorBB[square_color(s)] & p.bishops(them)) == EmptyBoardBB)
- bonus += v;
- }
- ei.mgValue += Sign[us] * bonus;
- ei.egValue += Sign[us] * bonus;
+ // evaluate_outposts() evaluates bishop and knight outposts squares
+
+ template<PieceType Piece>
+ void evaluate_outposts(const Position& p, Color us, Color them, EvalInfo& ei, Square s) {
+
+ // Initial bonus based on square
+ Value bonus = (Piece == BISHOP ? BishopOutpostBonus[relative_square(us, s)]
+ : KnightOutpostBonus[relative_square(us, s)]);
+
+ // Increase bonus if supported by pawn, especially if the opponent has
+ // no minor piece which can exchange the outpost piece
+ if (bonus && (p.pawn_attacks(them, s) & p.pawns(us)))
+ {
+ if ( p.knights(them) == EmptyBoardBB
+ && (SquaresByColorBB[square_color(s)] & p.bishops(them)) == EmptyBoardBB)
+ bonus += bonus + bonus / 2;
+ else
+ bonus += bonus / 2;