- for (File f = FILE_A; f <= FILE_H; ++f)
- AdjacentFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
-
- for (Rank r = RANK_1; r < RANK_8; ++r)
- InFrontBB[WHITE][r] = ~(InFrontBB[BLACK][r + 1] = InFrontBB[BLACK][r] | RankBB[r]);
-
- for (Color c = WHITE; c <= BLACK; ++c)
- for (Square s = SQ_A1; s <= SQ_H8; ++s)
- {
- ForwardBB[c][s] = InFrontBB[c][rank_of(s)] & FileBB[file_of(s)];
- PawnAttackSpan[c][s] = InFrontBB[c][rank_of(s)] & AdjacentFilesBB[file_of(s)];
- PassedPawnMask[c][s] = ForwardBB[c][s] | PawnAttackSpan[c][s];
- }
-
- for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
- for (Square s2 = SQ_A1; s2 <= SQ_H8; ++s2)
- {
- SquareDistance[s1][s2] = std::max(file_distance(s1, s2), rank_distance(s1, s2));
- if (s1 != s2)
- DistanceRingsBB[s1][SquareDistance[s1][s2] - 1] |= s2;
- }
-
- int steps[][9] = { {}, { 7, 9 }, { 17, 15, 10, 6, -6, -10, -15, -17 },
- {}, {}, {}, { 9, 7, -7, -9, 8, 1, -1, -8 } };
+ // Helper returning the target bitboard of a step from a square
+ auto landing_square_bb = [&](Square s, int step)
+ {
+ Square to = Square(s + step);
+ return is_ok(to) && distance(s, to) <= 2 ? square_bb(to) : Bitboard(0);
+ };