diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 2698c813..cd535d88 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -695,7 +695,7 @@ namespace { behind |= shift(behind); int bonus = popcount(safe) + popcount(behind & safe & ~attackedBy[Them][ALL_PIECES]); - int weight = pos.count(Us) - 1; + int weight = pos.count(Us) - 2 + pe->blocked_count() / 2; Score score = make_score(bonus * weight * weight / 16, 0); if (T) diff --git a/src/pawns.cpp b/src/pawns.cpp index 63bc596f..7c4eda0f 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -86,6 +86,7 @@ namespace { e->passedPawns[Us] = 0; e->kingSquares[Us] = SQ_NONE; e->pawnAttacks[Us] = e->pawnAttacksSpan[Us] = pawn_attacks_bb(ourPawns); + e->blockedCount[Us] = 0; // Loop through all pawns of the current color and score each pawn while ((s = *pl++) != SQ_NONE) @@ -105,6 +106,8 @@ namespace { phalanx = neighbours & rank_bb(s); support = neighbours & rank_bb(s - Up); + e->blockedCount[Us] += bool(blocked); + // A pawn is backward when it is behind all pawns of the same color on // the adjacent files and cannot safely advance. backward = !(neighbours & forward_ranks_bb(Them, s + Up)) diff --git a/src/pawns.h b/src/pawns.h index bd17618f..41a88c6f 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -38,6 +38,7 @@ struct Entry { Bitboard passed_pawns(Color c) const { return passedPawns[c]; } Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; } int passed_count() const { return popcount(passedPawns[WHITE] | passedPawns[BLACK]); } + int blocked_count() const { return blockedCount[WHITE] + blockedCount[BLACK]; } template Score king_safety(const Position& pos) { @@ -59,6 +60,7 @@ struct Entry { Square kingSquares[COLOR_NB]; Score kingSafety[COLOR_NB]; int castlingRights[COLOR_NB]; + int blockedCount[COLOR_NB]; }; typedef HashTable Table;