X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbitboard.cpp;h=1e07c8ce32bda3cc2eba58cd98a7aec83fcc2360;hb=9da1f45b1d310fbe213a7f51916e098fba837a9a;hp=23ff18172834720e0538b309cf3b1fb08294a080;hpb=57c51dd1ef2037801b7b8a97837bec65eb98d827;p=stockfish diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 23ff1817..1e07c8ce 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -248,7 +248,6 @@ namespace { void init_attacks(); void init_between_bitboards(); void init_pseudo_attacks(); - SquareDelta ray_direction(Square orig, Square dest); Bitboard index_to_bitboard(int index, Bitboard mask); Bitboard sliding_attacks(int sq, Bitboard block, int dirs, int deltas[][2], int fmin, int fmax, int rmin, int rmax); @@ -288,10 +287,10 @@ void init_bitboards() { 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(); } @@ -454,31 +453,27 @@ namespace { return result; } - SquareDelta ray_direction(Square orig, Square dest) { - - int df = file_distance(orig, dest); - int dr = rank_distance(orig, dest); - - if (orig != dest && (!df || !dr || df == dr)) - return SquareDelta(dest - orig) / Max(df, dr); - - return DELTA_NONE; - } - void init_between_bitboards() { Square s1, s2, s3; 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 = ray_direction(s1, s2); - if (d != DELTA_NONE) + if (bit_is_set(QueenPseudoAttacks[s1], s2)) + { + f = file_distance(s1, s2); + r = rank_distance(s1, s2); + + d = SquareDelta(s2 - s1) / Max(f, r); + for (s3 = s1 + d; s3 != s2; s3 += d) set_bit(&(BetweenBB[s1][s2]), s3); + } } }