X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbitboard.h;h=0f55810cece9864471329997ae359d56877cc8d6;hb=527d832a6de81c455cc8818e85c309fa1443f862;hp=93f838f8a6adce42ead12022368fce28959f34c9;hpb=a5e3b4eddede900c1df610e8e25026a79d706500;p=stockfish diff --git a/src/bitboard.h b/src/bitboard.h index 93f838f8..0f55810c 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -200,12 +200,24 @@ inline Bitboard adjacent_files_bb(Square s) { return shift(file_bb(s)) | shift(file_bb(s)); } +/// line_bb(Square, Square) returns a Bitboard representing an entire line +/// (from board edge to board edge) that intersects the given squares. +/// If the given squares are not on a same file/rank/diagonal, return 0. +/// Ex. line_bb(SQ_C4, SQ_F7) returns a bitboard with the A2-G8 diagonal. + +inline Bitboard line_bb(Square s1, Square s2) { + + assert(is_ok(s1) && is_ok(s2)); + return LineBB[s1][s2]; +} -/// between_bb() returns squares that are linearly between the given squares +/// between_bb() returns a Bitboard representing squares that are linearly +/// between the given squares (excluding the given squares). /// If the given squares are not on a same file/rank/diagonal, return 0. +/// Ex. between_bb(SQ_C4, SQ_F7) returns a bitboard with squares D5 and E6. inline Bitboard between_bb(Square s1, Square s2) { - Bitboard b = LineBB[s1][s2] & ((AllSquares << s1) ^ (AllSquares << s2)); + Bitboard b = line_bb(s1, s2) & ((AllSquares << s1) ^ (AllSquares << s2)); return b & (b - 1); //exclude lsb } @@ -241,7 +253,7 @@ inline Bitboard pawn_attack_span(Color c, Square s) { /// the given color and on the given square is a passed pawn. inline Bitboard passed_pawn_span(Color c, Square s) { - return forward_ranks_bb(c, s) & (adjacent_files_bb(s) | file_bb(s)); + return pawn_attack_span(c, s) | forward_file_bb(c, s); } @@ -249,7 +261,7 @@ inline Bitboard passed_pawn_span(Color c, Square s) { /// straight or on a diagonal line. inline bool aligned(Square s1, Square s2, Square s3) { - return LineBB[s1][s2] & s3; + return line_bb(s1, s2) & s3; }