@@ -747,10 +747,8 @@ constexpr Score WeakQueen = S( 10, 2);// Gunther Dementz weak queen mo
747747 // If the pawn is free to advance, then increase the bonus
748748 if (pos.empty (blockSq))
749749 {
750- // If there is a rook or queen attacking/defending the pawn from behind,
751- // consider all the squaresToQueen. Otherwise consider only the squares
752- // in the pawn's path attacked or occupied by the enemy.
753- defendedSquares = unsafeSquares = squaresToQueen = forward_file_bb (Us, s);
750+ defendedSquares = squaresToQueen = forward_file_bb (Us, s);
751+ unsafeSquares = passed_pawn_span (Us, s);
754752
755753 bb = forward_file_bb (Them, s) & pos.pieces (ROOK, QUEEN);
756754
@@ -760,9 +758,13 @@ constexpr Score WeakQueen = S( 10, 2);// Gunther Dementz weak queen mo
760758 if (!(pos.pieces (Them) & bb))
761759 unsafeSquares &= attackedBy[Them][ALL_PIECES] | pos.pieces (Them);
762760
763- // If there aren't any enemy attacks, assign a big bonus. Otherwise
764- // assign a smaller bonus if the block square isn't attacked.
765- int k = !unsafeSquares ? 20 : !(unsafeSquares & blockSq) ? 9 : 0 ;
761+ // If there are no enemy attacks on passed pawn span, assign a big bonus.
762+ // Otherwise assign a smaller bonus if the path to queen is not attacked
763+ // and even smaller bonus if it is attacked but block square is not.
764+ int k = !unsafeSquares ? 35 :
765+ !(unsafeSquares & squaresToQueen) ? 20 :
766+ !(unsafeSquares & blockSq) ? 9 :
767+ 0 ;
766768
767769 // Assign a larger bonus if the block square is defended.
768770 if (defendedSquares & blockSq)
0 commit comments