#undef S
const Score Tempo = make_score(24, 11);
- const Score RookOn7th = make_score(11, 20);
const Score RookOnPawn = make_score(10, 28);
const Score RookOpenFile = make_score(43, 21);
const Score RookSemiopenFile = make_score(19, 10);
const Score BishopPawns = make_score( 8, 12);
- const Score KnightPawns = make_score( 8, 4);
const Score MinorBehindPawn = make_score(16, 0);
const Score UndefendedMinor = make_score(25, 10);
const Score TrappedRook = make_score(90, 0);
if (Pt == BISHOP)
score -= BishopPawns * ei.pi->pawns_on_same_color_squares(Us, s);
- // Penalty for knight when there are few enemy pawns
- if (Pt == KNIGHT)
- score -= KnightPawns * std::max(5 - pos.count<PAWN>(Them), 0);
-
// Bishop and knight outposts squares
if (!(pos.pieces(Them, PAWN) & pawn_attack_span(Us, s)))
score += evaluate_outposts<Pt, Us>(pos, ei, s);
if (Pt == ROOK)
{
- // Rook on 7th rank and enemy king trapped on 8th
- if ( relative_rank(Us, s) == RANK_7
- && relative_rank(Us, pos.king_square(Them)) == RANK_8)
- score += RookOn7th;
-
// Rook piece attacking enemy pawns on the same rank/file
if (relative_rank(Us, s) >= RANK_5)
{
else
defendedSquares = squaresToQueen & ei.attackedBy[Us][ALL_PIECES];
- // If there aren't any enemy attacks, then assign a huge bonus.
- // The bonus will be a bit smaller if at least the block square
- // isn't attacked, otherwise assign the smallest possible bonus.
- int k = !unsafeSquares ? 15 : !(unsafeSquares & blockSq) ? 9 : 3;
+ // If there aren't any enemy attacks, assign a big bonus. Otherwise
+ // assign a smaller bonus if the block square isn't attacked.
+ int k = !unsafeSquares ? 15 : !(unsafeSquares & blockSq) ? 9 : 0;
- // Assign a big bonus if the path to the queen is fully defended,
- // otherwise assign a bit less of a bonus if at least the block
- // square is defended.
+ // If the path to queen is fully defended, assign a big bonus.
+ // Otherwise assign a smaller bonus if the block square is defended.
if (defendedSquares == squaresToQueen)
k += 6;
else if (defendedSquares & blockSq)
- k += (unsafeSquares & defendedSquares) == unsafeSquares ? 4 : 2;
+ k += 4;
mbonus += Value(k * rr), ebonus += Value(k * rr);
}
} // rr != 0
- // 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,
- // we try the following: Increase the value for rook pawns if the
- // other side has no pieces apart from a knight, and decrease the
- // value if the other side has a rook or queen.
- if (file_of(s) == FILE_A || file_of(s) == FILE_H)
- {
- if (pos.non_pawn_material(Them) <= KnightValueMg)
- ebonus += ebonus / 4;
-
- else if (pos.pieces(Them, ROOK, QUEEN))
- ebonus -= ebonus / 4;
- }
-
if (pos.count<PAWN>(Us) < pos.count<PAWN>(Them))
ebonus += ebonus / 4;