- // 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)
- {
- b = outpost_mask(Us, s) & theirPawns & (FileFBB | FileGBB | FileHBB);
- while (b)
- {
- // Give a bonus according to the distance of the nearest enemy pawn
- s2 = pop_1st_bit(&b);
- r2 = square_rank(s2);
- v = StormLeverBonus[f] - 2 * rank_distance(r, r2);
-
- // 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;
+ // Calculate kingside and queenside pawn storm scores for both colors to be
+ // used when evaluating middle game positions with opposite side castling.
+ bonus = (f >= FILE_F ? evaluate_pawn_storm<Us, KingSide>(s, r, f, theirPawns) : 0);
+ pi->ksStormValue[Us] += KStormTable[relative_square(Us, s)] + bonus;