&& pos.non_pawn_material(BLACK) == RookValueMg
&& pos.count<PAWN>(strongSide) - pos.count<PAWN>(~strongSide) <= 1
&& bool(KingSide & pos.pieces(strongSide, PAWN)) != bool(QueenSide & pos.pieces(strongSide, PAWN))
- && (attackedBy[~strongSide][KING] & pos.pieces(~strongSide, PAWN)))
++ && pos.count<KING>(~strongSide)
+ && (attacks_bb<KING>(pos.square<KING>(~strongSide)) & pos.pieces(~strongSide, PAWN)))
sf = 36;
else if (pos.count<QUEEN>() == 1)
sf = 37 + 3 * (pos.count<QUEEN>(WHITE) == 1 ? pos.count<BISHOP>(BLACK) + pos.count<KNIGHT>(BLACK)
score += pe->pawn_score(WHITE) - pe->pawn_score(BLACK);
// Early exit if score is high
- Value v = (mg_value(score) + eg_value(score)) / 2;
- if (abs(v) > LazyThreshold + pos.non_pawn_material() / 64 && Options["UCI_Variant"] == "chess")
- return pos.side_to_move() == WHITE ? v : -v;
+ auto lazy_skip = [&](Value lazyThreshold) {
+ return abs(mg_value(score) + eg_value(score)) / 2 > lazyThreshold + pos.non_pawn_material() / 64;
+ };
+
- if (lazy_skip(LazyThreshold1))
++ if (lazy_skip(LazyThreshold1) && Options["UCI_Variant"] == "chess")
+ goto make_v;
// Main evaluation begins here
initialize<WHITE>();
// More complex interactions that require fully populated attack bitboards
score += king< WHITE>() - king< BLACK>()
- + threats<WHITE>() - threats<BLACK>()
- + passed< WHITE>() - passed< BLACK>();
+ + passed< WHITE>() - passed< BLACK>()
- + space< WHITE>() - space< BLACK>()
+ + variant<WHITE>() - variant<BLACK>();
- if (lazy_skip(LazyThreshold2))
++ if (lazy_skip(LazyThreshold2) && Options["UCI_Variant"] == "chess")
+ goto make_v;
+
+ score += threats<WHITE>() - threats<BLACK>()
+ + space< WHITE>() - space< BLACK>();
+
+ make_v:
// Derive single value from mg and eg parts of score
- v = winnable(score);
+ Value v = winnable(score);
// In case of tracing add all remaining individual evaluation terms
if (T)
}
}
- probcutBeta = beta + 176 - 49 * improving;
++ probcutBeta = beta + (176 + 20 * !!pos.capture_the_flag_piece()) * (1 + pos.check_counting() + (pos.extinction_value() != VALUE_NONE)) - 49 * improving;
+
// Step 10. ProbCut (~10 Elo)
// If we have a good enough capture and a reduced search returns a value
// much above beta, we can (almost) safely prune the previous move.
if (type_of(move) == CASTLING)
extension = 1;
- // Late irreversible move extension
- if ( move == ttMove
- && pos.rule50_count() > 80
- && (captureOrPromotion || type_of(movedPiece) == PAWN))
- extension = 2;
-
+ // Losing chess capture extension
+ else if ( pos.must_capture()
+ && pos.capture(move)
+ && MoveList<CAPTURES>(pos).size() == 1)
+ extension = 1;
+
// Add extension to new depth
newDepth += extension;