From 170bdf40cd47f7f3a601107fae0a32667a9d72a9 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 7 Feb 2015 11:15:38 +0100 Subject: [PATCH 1/2] Rename dbg_hit_on_c() to dbg_hit_on() Use an overload instead of a new named function. I have found this handier and easier when adding some quick debug code. No functional change. --- src/evaluate.cpp | 2 +- src/misc.cpp | 2 +- src/misc.h | 2 +- src/position.cpp | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 822be015..be3c6497 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -559,7 +559,7 @@ namespace { & pos.pieces(Them) & ~ei.attackedBy[Us][PAWN]; - if(b) + if (b) score += popcount(b) * PawnAttackThreat; if (Trace) diff --git a/src/misc.cpp b/src/misc.cpp index 656b3155..aa2b2331 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -126,7 +126,7 @@ const string engine_info(bool to_uci) { /// Debug functions used mainly to collect run-time statistics void dbg_hit_on(bool b) { ++hits[0]; if (b) ++hits[1]; } -void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); } +void dbg_hit_on(bool c, bool b) { if (c) dbg_hit_on(b); } void dbg_mean_of(int v) { ++means[0]; means[1] += v; } void dbg_print() { diff --git a/src/misc.h b/src/misc.h index 965a0ee8..246a56a0 100644 --- a/src/misc.h +++ b/src/misc.h @@ -33,7 +33,7 @@ void prefetch(char* addr); void start_logger(bool b); void dbg_hit_on(bool b); -void dbg_hit_on_c(bool c, bool b); +void dbg_hit_on(bool c, bool b); void dbg_mean_of(int v); void dbg_print(); diff --git a/src/position.cpp b/src/position.cpp index 994e1c76..ef31d58d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -47,7 +47,7 @@ namespace Zobrist { Key exclusion; } -Key Position::exclusion_key() const { return st->key ^ Zobrist::exclusion;} +Key Position::exclusion_key() const { return st->key ^ Zobrist::exclusion; } namespace { @@ -1060,8 +1060,8 @@ Value Position::see(Move m) const { stm = color_of(piece_on(from)); occupied = pieces() ^ from; - // Castling moves are implemented as king capturing the rook so cannot be - // handled correctly. Simply return 0 that is always the correct value + // Castling moves are implemented as king capturing the rook so cannot + // be handled correctly. Simply return VALUE_ZERO that is always correct // unless in the rare case the rook ends up under attack. if (type_of(m) == CASTLING) return VALUE_ZERO; From e118570038f2d9b668b445fe6d31df94151a717b Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Sun, 8 Feb 2015 19:20:39 +0000 Subject: [PATCH 2/2] Pawn Center Bind Bonus Bonus for two pawns controlling the same central square STC: LLR: 3.14 (-2.94,2.94) [-1.50,4.50] Total: 15974 W: 3291 L: 3133 D: 9550 LTC: LLR: 3.24 (-2.94,2.94) [0.00,6.00] Total: 10449 W: 1837 L: 1674 D: 6938 Idea from Lyudmil Tsvetkov. Bench: 7699138 Resolves #248 --- src/pawns.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pawns.cpp b/src/pawns.cpp index ef456307..d66233ca 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -61,6 +61,14 @@ namespace { // Unsupported pawn penalty const Score UnsupportedPawnPenalty = S(20, 10); + // Center bind bonus: Two pawns controlling the same central square + const Bitboard CenterBindMask[COLOR_NB] = { + (FileDBB | FileEBB) & (Rank5BB | Rank6BB | Rank7BB), + (FileDBB | FileEBB) & (Rank4BB | Rank3BB | Rank2BB) + }; + + const Score CenterBind = S(16, 0); + // Weakness of our pawn shelter in front of the king by [distance from edge][rank] const Value ShelterWeakness[][RANK_NB] = { { V( 99), V(20), V(26), V(54), V(85), V( 92), V(108) }, @@ -195,6 +203,10 @@ namespace { b = e->semiopenFiles[Us] ^ 0xFF; e->pawnSpan[Us] = b ? int(msb(b) - lsb(b)) : 0; + // Center binds: Two pawns controlling the same central square + b = shift_bb(ourPawns) & shift_bb(ourPawns) & CenterBindMask[Us]; + score += popcount(b) * CenterBind; + return score; }