init_masks();
init_attacks();
- init_between_bitboards();
init_sliding_attacks(RAttacks, RAttackIndex, RMask, RShift, RMult, rookDeltas);
init_sliding_attacks(BAttacks, BAttackIndex, BMask, BShift, BMult, bishopDeltas);
init_pseudo_attacks();
+ init_between_bitboards();
}
void init_between_bitboards() {
- const SquareDelta directionToDelta[] = {
- DELTA_E, DELTA_N, DELTA_NE, DELTA_NW, DELTA_W, DELTA_S, DELTA_SW, DELTA_SE
- };
-
Square s1, s2, s3;
- Direction d;
+ SquareDelta d;
+ int f, r;
for (s1 = SQ_A1; s1 <= SQ_H8; s1++)
for (s2 = SQ_A1; s2 <= SQ_H8; s2++)
{
BetweenBB[s1][s2] = EmptyBoardBB;
- d = direction_between_squares(s1, s2);
- if (d == DIR_NONE)
- continue;
+ if (bit_is_set(QueenPseudoAttacks[s1], s2))
+ {
+ f = file_distance(s1, s2);
+ r = rank_distance(s1, s2);
- SquareDelta sd = directionToDelta[s2 > s1 ? d : d + 4];
+ d = SquareDelta(s2 - s1) / Max(f, r);
- for (s3 = s1 + sd; s3 != s2; s3 += sd)
- set_bit(&(BetweenBB[s1][s2]), s3);
+ for (s3 = s1 + d; s3 != s2; s3 += d)
+ set_bit(&(BetweenBB[s1][s2]), s3);
+ }
}
}