Skip to content

Commit cc40d1c

Browse files
committed
Merge Joona's bishop+pawn tweak
The idea is to penalize a bishop in case of its pawns are on the same colored squares. Good at short 15"+0.05 TC LLR: 2.95 (-2.94,2.94) Total: 4252 W: 925 L: 806 D: 2521 And at longer 60"+0.05 TC LLR: 2.95 (-2.94,2.94) Total: 15006 W: 2743 L: 2564 D: 9699 bench: 5274705
2 parents 87436e5 + 818e0b2 commit cc40d1c

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

src/bitboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
6363
extern Bitboard AttackSpanMask[COLOR_NB][SQUARE_NB];
6464
extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
6565

66+
const Bitboard WhiteSquares = 0x55AA55AA55AA55AAULL;
67+
const Bitboard BlackSquares = 0xAA55AA55AA55AA55ULL;
6668

6769
/// Overloads of bitwise operators between a Bitboard and a Square for testing
6870
/// whether a given bit is set in a bitboard, and for setting and clearing bits.

src/evaluate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,10 @@ Value do_evaluate(const Position& pos, Value& margin) {
582582
&& !more_than_one(BetweenBB[s][pos.king_square(Them)] & pos.pieces()))
583583
score += BishopPinBonus;
584584

585+
// Penalty for bishop with same coloured pawns
586+
if (Piece == BISHOP)
587+
score -= make_score(8, 12) * ei.pi->same_colored_pawn_count(s, Us);
588+
585589
// Bishop and knight outposts squares
586590
if ( (Piece == BISHOP || Piece == KNIGHT)
587591
&& !(pos.pieces(Them, PAWN) & attack_span_mask(Us, s)))

src/material.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace {
4646
{ 7 }, // Bishop pair
4747
{ 39, 2 }, // Pawn
4848
{ 35, 271, -4 }, // Knight
49-
{ 7, 25, 4, 7 }, // Bishop
49+
{ 7, 105, 4, 7 }, // Bishop
5050
{ -27, -2, 46, 100, 56 }, // Rook
5151
{ 58, 29, 83, 148, -3, -25 } // Queen
5252
};

src/pawns.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ namespace {
176176
value += CandidateBonus[relative_rank(Us, s)];
177177
}
178178

179+
e->pawnsOnWhiteSquaresCount[Us] = popcount<Max15>(ourPawns & WhiteSquares);
180+
e->pawnsOnWhiteSquaresCount[Them] = popcount<Max15>(theirPawns & WhiteSquares);
181+
182+
e->pawnsOnBlackSquaresCount[Us] = popcount<Max15>(ourPawns & BlackSquares);
183+
e->pawnsOnBlackSquaresCount[Them] = popcount<Max15>(theirPawns & BlackSquares);
184+
179185
return value;
180186
}
181187
}

src/pawns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Entry {
4040
int file_is_half_open(Color c, File f) const { return halfOpenFiles[c] & (1 << int(f)); }
4141
int has_open_file_to_left(Color c, File f) const { return halfOpenFiles[c] & ((1 << int(f)) - 1); }
4242
int has_open_file_to_right(Color c, File f) const { return halfOpenFiles[c] & ~((1 << int(f+1)) - 1); }
43+
int same_colored_pawn_count(Square s, Color c) const { return (BlackSquares & s) ? pawnsOnBlackSquaresCount[c] : pawnsOnWhiteSquaresCount[c]; }
4344

4445
template<Color Us>
4546
Score king_safety(const Position& pos, Square ksq) {
@@ -63,6 +64,8 @@ struct Entry {
6364
Score value;
6465
int halfOpenFiles[COLOR_NB];
6566
Score kingSafety[COLOR_NB];
67+
int pawnsOnWhiteSquaresCount[COLOR_NB];
68+
int pawnsOnBlackSquaresCount[COLOR_NB];
6669
};
6770

6871
typedef HashTable<Entry, 16384> Table;

0 commit comments

Comments
 (0)