// Middle-game specific evaluation terms
if (phase > PHASE_ENDGAME)
{
- // Pawn storms in positions with opposite castling
- if ( square_file(pos.king_square(WHITE)) >= FILE_E
- && square_file(pos.king_square(BLACK)) <= FILE_D)
+ // Pawn storms in positions with opposite castling
+ if ( square_file(pos.king_square(WHITE)) >= FILE_E
+ && square_file(pos.king_square(BLACK)) <= FILE_D)
- ei.value += make_score(ei.pi->queenside_storm_value(WHITE) - ei.pi->kingside_storm_value(BLACK), 0);
+ ei.value += make_score(ei.pi->queenside_storm_value(WHITE) - ei.pi->kingside_storm_value(BLACK), 0);
- else if ( square_file(pos.king_square(WHITE)) <= FILE_D
- && square_file(pos.king_square(BLACK)) >= FILE_E)
+ else if ( square_file(pos.king_square(WHITE)) <= FILE_D
+ && square_file(pos.king_square(BLACK)) >= FILE_E)
- ei.value += make_score(ei.pi->kingside_storm_value(WHITE) - ei.pi->queenside_storm_value(BLACK), 0);
+ ei.value += make_score(ei.pi->kingside_storm_value(WHITE) - ei.pi->queenside_storm_value(BLACK), 0);
- // Evaluate space for both sides
- if (ei.mi->space_weight() > 0)
- {
- evaluate_space<WHITE, HasPopCnt>(pos, ei);
- evaluate_space<BLACK, HasPopCnt>(pos, ei);
- }
+ // Evaluate space for both sides
+ if (ei.mi->space_weight() > 0)
+ {
+ evaluate_space<WHITE, HasPopCnt>(pos, ei);
+ evaluate_space<BLACK, HasPopCnt>(pos, ei);
+ }
}
// Mobility
{
Square s = pop_1st_bit(&b);
- assert(pos.piece_on(s) == piece_of_color_and_type(Us, PAWN));
assert(pos.pawn_is_passed(Us, s));
int r = int(relative_rank(Us, s) - RANK_2);
squaresToQueen = squares_in_front_of(Us, s);
defendedSquares = squaresToQueen & ei.attacked_by(Us);
- // There are no enemy pawns in the pawn's path
- assert(!(squaresToQueen & pos.pieces(PAWN, Them)));
-
// If there is an enemy rook or queen attacking the pawn from behind,
// add all X-ray attacks by the rook or queen. Otherwise consider only
// the squares in the pawn's path attacked or occupied by the enemy.
Square s = pop_1st_bit(&b);
Square queeningSquare = relative_square(c, make_square(square_file(s), RANK_8));
int d = square_distance(s, queeningSquare)
+ - (relative_rank(c, s) == RANK_2) // Double pawn push
- square_distance(pos.king_square(opposite_color(c)), queeningSquare)
+ int(c != pos.side_to_move());