X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=06adbfe3850512902633fe3b514dff664863bb90;hp=a53f348b2fb268eb412bebbdfc967c6f70b5b072;hb=1fd020a8ba98a95775639cdebd19e3592b767eb3;hpb=02420d4670e54f41bce5bc6d53fb437b80f9d534 diff --git a/src/bitboard.h b/src/bitboard.h index a53f348b..06adbfe3 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -96,6 +96,18 @@ inline bool more_than_one(Bitboard b) { } +/// shift_bb() moves bitboard one step along direction Delta. Mainly for pawns. + +template +inline Bitboard shift_bb(Bitboard b) { + + return Delta == DELTA_N ? b << 8 : Delta == DELTA_S ? b >> 8 + : Delta == DELTA_NE ? (b & ~FileHBB) << 9 : Delta == DELTA_SE ? (b & ~FileHBB) >> 7 + : Delta == DELTA_NW ? (b & ~FileABB) << 7 : Delta == DELTA_SW ? (b & ~FileABB) >> 9 + : 0; +} + + /// rank_bb() and file_bb() take a file or a square as input and return /// a bitboard representing all squares on the given file or rank.