Skip to content

Commit 4b9e338

Browse files
R-Pelegmcostalba
authored andcommitted
Bonus for rook behind a passed
If our rook is behind a passed pawn, all squares are defended. One of the longest tests to pass ! Passed both short TC LLR: 2.97 (-2.94,2.94) Total: 44560 W: 9518 L: 9281 D: 25761 And long TC LLR: 2.96 (-2.94,2.94) Total: 61348 W: 11618 L: 11192 D: 38538 bench: 3787694
1 parent a0cf424 commit 4b9e338

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/evaluate.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,6 @@ Value do_evaluate(const Position& pos, Value& margin) {
826826
if (pos.is_empty(blockSq))
827827
{
828828
squaresToQueen = forward_bb(Us, s);
829-
defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES];
830829

831830
// If there is an enemy rook or queen attacking the pawn from behind,
832831
// add all X-ray attacks by the rook or queen. Otherwise consider only
@@ -837,6 +836,12 @@ Value do_evaluate(const Position& pos, Value& margin) {
837836
else
838837
unsafeSquares = squaresToQueen & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
839838

839+
if ( unlikely(forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN))
840+
&& (forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN) & pos.attacks_from<ROOK>(s)))
841+
defendedSquares = squaresToQueen;
842+
else
843+
defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES];
844+
840845
// If there aren't enemy attacks huge bonus, a bit smaller if at
841846
// least block square is not attacked, otherwise smallest bonus.
842847
int k = !unsafeSquares ? 15 : !(unsafeSquares & blockSq) ? 9 : 3;

0 commit comments

Comments
 (0)