};
// Assorted bonuses and penalties
- constexpr Score AttacksOnSpaceArea = S( 4, 0);
constexpr Score BishopPawns = S( 3, 7);
constexpr Score CorneredBishop = S( 50, 50);
constexpr Score FlankAttacks = S( 8, 0);
return std::min(distance(pos.square<KING>(c), s), 5);
};
- Bitboard b, bb, squaresToQueen, defendedSquares, unsafeSquares;
+ Bitboard b, bb, squaresToQueen, unsafeSquares;
Score score = SCORE_ZERO;
b = pe->passed_pawns(Us);
// If the pawn is free to advance, then increase the bonus
if (pos.empty(blockSq))
{
- defendedSquares = squaresToQueen = forward_file_bb(Us, s);
+ squaresToQueen = forward_file_bb(Us, s);
unsafeSquares = passed_pawn_span(Us, s);
bb = forward_file_bb(Them, s) & pos.pieces(ROOK, QUEEN);
- if (!(pos.pieces(Us) & bb))
- defendedSquares &= attackedBy[Us][ALL_PIECES];
-
if (!(pos.pieces(Them) & bb))
unsafeSquares &= attackedBy[Them][ALL_PIECES] | pos.pieces(Them);
0 ;
// Assign a larger bonus if the block square is defended
- if (defendedSquares & blockSq)
+ if ((pos.pieces(Us) & bb) || (attackedBy[Us][ALL_PIECES] & blockSq))
k += 5;
bonus += make_score(k * w, k * w);
// Scale down bonus for candidate passers which need more than one
// pawn push to become passed, or have a pawn in front of them.
if ( !pos.pawn_passed(Us, s + Up)
- || (pos.pieces(PAWN) & forward_file_bb(Us, s)))
+ || (pos.pieces(PAWN) & (s + Up)))
bonus = bonus / 2;
score += bonus + PassedFile[file_of(s)];
behind |= shift<Down>(behind);
behind |= shift<Down+Down>(behind);
- int bonus = popcount(safe) + popcount(behind & safe);
+ int bonus = popcount(safe) + popcount(behind & safe & ~attackedBy[Them][ALL_PIECES]);
int weight = pos.count<ALL_PIECES>(Us) - 1;
Score score = make_score(bonus * weight * weight / 16, 0);
- score -= AttacksOnSpaceArea * popcount(attackedBy[Them][ALL_PIECES] & behind & safe);
-
if (T)
Trace::add(SPACE, Us, score);