Skip to content

Commit

Permalink
Merge Joona's bishop+pawn tweak
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mcostalba committed Apr 19, 2013
2 parents 87436e5 + 818e0b2 commit cc40d1c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bitboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion src/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
6 changes: 6 additions & 0 deletions src/pawns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ namespace {
value += CandidateBonus[relative_rank(Us, s)];
}

e->pawnsOnWhiteSquaresCount[Us] = popcount<Max15>(ourPawns & WhiteSquares);
e->pawnsOnWhiteSquaresCount[Them] = popcount<Max15>(theirPawns & WhiteSquares);

e->pawnsOnBlackSquaresCount[Us] = popcount<Max15>(ourPawns & BlackSquares);
e->pawnsOnBlackSquaresCount[Them] = popcount<Max15>(theirPawns & BlackSquares);

return value;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/pawns.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color Us>
Score king_safety(const Position& pos, Square ksq) {
Expand All @@ -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<Entry, 16384> Table;
Expand Down

0 comments on commit cc40d1c

Please sign in to comment.