From deee18c758ce8a52a2dfa9bff1fdea01c6e79a59 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 2 Jan 2011 11:45:03 +0100 Subject: [PATCH] Another (final?) attempt at squares_delta() This time I have removed the function alltogether ! Sorry to work above a patch of UncombedCoconut (Justin Blanchard) but I couldn't resist ;-) No functional change. Signed-off-by: Marco Costalba --- src/bitboard.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) 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); + } } } -- 2.39.2