- 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));
-
- for (Square s1 = SQ_A1; s1 <= SQ_H8; s1++)
- for (int d = 1; d < 8; d++)
- for (Square s2 = SQ_A1; s2 <= SQ_H8; s2++)
- if (SquareDistance[s1][s2] == d)
- DistanceRingsBB[s1][d - 1] |= s2;
-
- int steps[][9] = { {}, { 7, 9 }, { 17, 15, 10, 6, -6, -10, -15, -17 },
- {}, {}, {}, { 9, 7, -7, -9, 8, 1, -1, -8 } };
-
- for (Color c = WHITE; c <= BLACK; c++)
- for (PieceType pt = PAWN; pt <= KING; pt++)
- for (Square s = SQ_A1; s <= SQ_H8; s++)
- for (int k = 0; steps[pt][k]; k++)
- {
- Square to = s + Square(c == WHITE ? steps[pt][k] : -steps[pt][k]);