// number and types of the enemy's attacking pieces, the number of
// attacked and undefended squares around our king and the quality of
// the pawn shelter (current 'score' value).
- kingDanger = std::min(820, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them])
+ kingDanger = ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]
+ 103 * ei.kingAdjacentZoneAttacksCount[Them]
+ 190 * popcount(undefended)
+ 142 * (popcount(b) + !!pos.pinned_pieces(Us))
{
Square s = pop_lsb(&b);
- assert(!(pos.pieces(PAWN) & forward_bb(Us, s)));
+ assert(!(pos.pieces(Them, PAWN) & forward_bb(Us, s + pawn_push(Us))));
bb = forward_bb(Us, s) & (ei.attackedBy[Them][ALL_PIECES] | pos.pieces(Them));
score -= HinderPassedPawn * popcount(bb);
} // rr != 0
// Scale down bonus for candidate passers which need more than one
- // pawn push to become passed.
- if (!pos.pawn_passed(Us, s + pawn_push(Us)))
+ // pawn push to become passed or have a pawn in front of them.
+ if (!pos.pawn_passed(Us, s + pawn_push(Us)) || (pos.pieces(PAWN) & forward_bb(Us, s)))
mbonus /= 2, ebonus /= 2;
score += make_score(mbonus, ebonus) + PassedFile[file_of(s)];