- // We calculate kingside and queenside pawn storm
- // scores for both colors. These are used when evaluating
- // middle game positions with opposite side castling.
- //
- // Each pawn is given a base score given by a piece square table
- // (KStormTable[] or QStormTable[]). Pawns which seem to have good
- // chances of creating an open file by exchanging itself against an
- // enemy pawn on an adjacent file gets an additional bonus.
-
- // Kingside pawn storms
- bonus = KStormTable[relative_square(Us, s)];
- if (f >= FILE_F)
- {
- Bitboard b = outpost_mask(Us, s) & theirPawns & (FileFBB | FileGBB | FileHBB);
- while (b)
- {
- // Give a bonus according to the distance of the nearest enemy pawn
- Square s2 = pop_1st_bit(&b);
- int v = StormLeverBonus[f] - 2 * square_distance(s, s2);
-
- // If enemy pawn has no pawn beside itself is particularly vulnerable.
- // Big bonus, especially against a weakness on the rook file
- if (!(theirPawns & neighboring_files_bb(s2) & rank_bb(s2)))
- v *= (square_file(s2) == FILE_H ? 4 : 2);
-
- bonus += v;
- }
- }
- pi->ksStormValue[Us] += bonus;
-
- // Queenside pawn storms
- bonus = QStormTable[relative_square(Us, s)];
- if (f <= FILE_C)
- {
- Bitboard b = outpost_mask(Us, s) & theirPawns & (FileABB | FileBBB | FileCBB);
- while (b)
- {
- // Give a bonus according to the distance of the nearest enemy pawn
- Square s2 = pop_1st_bit(&b);
- int v = StormLeverBonus[f] - 4 * square_distance(s, s2);
-
- // If enemy pawn has no pawn beside itself is particularly vulnerable.
- // Big bonus, especially against a weakness on the rook file
- if (!(theirPawns & neighboring_files_bb(s2) & rank_bb(s2)))
- v *= (square_file(s2) == FILE_A ? 4 : 2);
-
- bonus += v;
- }
- }
- pi->qsStormValue[Us] += bonus;