diff --git a/src/bitboard.h b/src/bitboard.h index 2c51b073de3..142c4c5a397 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -63,6 +63,8 @@ extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB]; extern Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB]; extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB]; +const Bitboard WhiteSquares = 0x55AA55AA55AA55AAULL; +const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL; /// Overloads of bitwise operators between a Bitboard and a Square for testing /// whether a given bit is set in a bitboard, and for setting and clearing bits. diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 6990a71d2bb..dd26e46986e 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -582,6 +582,10 @@ Value do_evaluate(const Position& pos, Value& margin) { && !more_than_one(BetweenBB[s][pos.king_square(Them)] & pos.pieces())) score += BishopPinBonus; + // Penalty for bishop with same coloured pawns + if (Piece == BISHOP) + score -= make_score(8, 12) * ei.pi->same_colored_pawn_count(s, Us); + // Bishop and knight outposts squares if ( (Piece == BISHOP || Piece == KNIGHT) && !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s))) diff --git a/src/material.cpp b/src/material.cpp index 9cc8eeadc47..208227e5223 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -46,7 +46,7 @@ namespace { { 7 }, // Bishop pair { 39, 2 }, // Pawn { 35, 271, -4 }, // Knight - { 7, 25, 4, 7 }, // Bishop + { 7, 105, 4, 7 }, // Bishop { -27, -2, 46, 100, 56 }, // Rook { 58, 29, 83, 148, -3, -25 } // Queen }; diff --git a/src/pawns.cpp b/src/pawns.cpp index c1a93169bd7..3d99bfc6864 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -176,6 +176,12 @@ namespace { value += CandidateBonus[relative_rank(Us, s)]; } + e->pawnsOnWhiteSquaresCount[Us] = popcount(ourPawns & WhiteSquares); + e->pawnsOnWhiteSquaresCount[Them] = popcount(theirPawns & WhiteSquares); + + e->pawnsOnBlackSquaresCount[Us] = popcount(ourPawns & BlackSquares); + e->pawnsOnBlackSquaresCount[Them] = popcount(theirPawns & BlackSquares); + return value; } } diff --git a/src/pawns.h b/src/pawns.h index 2c04e7d2eaa..3ec62334c96 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -40,6 +40,7 @@ struct Entry { int file_is_half_open(Color c, File f) const { return halfOpenFiles[c] & (1 << int(f)); } int has_open_file_to_left(Color c, File f) const { return halfOpenFiles[c] & ((1 << int(f)) - 1); } int has_open_file_to_right(Color c, File f) const { return halfOpenFiles[c] & ~((1 << int(f+1)) - 1); } + int same_colored_pawn_count(Square s, Color c) const { return (BlackSquares & s) ? pawnsOnBlackSquaresCount[c] : pawnsOnWhiteSquaresCount[c]; } template Score king_safety(const Position& pos, Square ksq) { @@ -63,6 +64,8 @@ struct Entry { Score value; int halfOpenFiles[COLOR_NB]; Score kingSafety[COLOR_NB]; + int pawnsOnWhiteSquaresCount[COLOR_NB]; + int pawnsOnBlackSquaresCount[COLOR_NB]; }; typedef HashTable Table;