There was this in the passed pawn eval already:
Code: Select all
// If the pawn is free to advance, increase bonus
if (pos.is_empty(blockSq))
{
squaresToQueen = forward_bb(Us, s);
defendedSquares = squaresToQueen & ei.attackedBy[Us][0];
Value bonuspoints;
// Passed pawn supported by our Rooks or Queen?
if ( (forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN))
&& (forward_bb(Them, s) & pos.pieces(Us, ROOK, QUEEN) & pos.attacks_from<ROOK>(s)))
{
rookqueenSupport = true;
if (ei.mi->game_phase() > PHASE_ENDGAME && (squaresToQueen & ei.kingRing[Them]))
mbonus += Value(rr * (10 - indirectBlock * 4 - passed_pawnAttacked * 2 + passed_pawnDefended * 2));
assert(passed_pawnDefended); //[always true here because of rook or queen behind]
}
Code: Select all
// If the pawn is free to advance, increase bonus
if (pos.is_empty(blockSq))
{
squaresToQueen = forward_bb(Us, s);
defendedSquares = squaresToQueen & ei.attackedBy[Us][0];
Code: Select all
// In the middle game, add bonuspoints if our passed pawn approaches the opponent king
if (ei.mi->game_phase() > PHASE_ENDGAME && (squaresToQueen & ei.kingRing[Them]))
mbonus += (ebonus/8) * int(pos.non_pawn_material(Us)/BishopValueMidgame); //[was: Value(rr * (10 - indirectBlock * 4 - passed_pawnAttacked * 2 + passed_pawnDefended * 2));]
// Rook pawns are a special case: They are sometimes worse, and
// sometimes better than other passed pawns. It is difficult to find
// good rules for determining whether they are good or bad. For now,
I don't think this first change is very important but having an extra bonus for Rooks on open files in the presence of passed pawns will help a bit more I think. I borrowed some code originally from Gary (Gary Linscott on Github) for this, from Stockfish Pawn shelter code:
Code: Select all
// Special extra evaluation for rooks
if (Piece == ROOK)
{
// Open and half-open files
f = file_of(s);
if (ei.pi->file_is_half_open(Us, f))
{
if (ei.pi->file_is_half_open(Them, f))
{
score += RookOpenFileBonus;
if (kingAttackCount > 0)
score += RookOpenKingfileBonus;
if (b = ei.pi->passed_pawns(Us) & (FileBB[f + 1] | FileBB[f - 1]))
{
Rank r = rank_of(Us == WHITE ? first_1(b) : ~last_1(b));
score += make_score((2 + 3 * kingAttackCount) * int(r) * int(r), 4 * int(r) * int(r));
}
}
else
score += RookHalfOpenFileBonus;
}
else if (!blockingOurPawn && ei.pi->file_is_half_open(Them, f))
score += RookAndPotentialCandidateBonus;
Regards, Eelco
