X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=559c70f62acf9e5f056d26f205fa6dc2aa24f38f;hp=3d629de1abe986d63cbf3801f7d1a421cb8006ed;hb=79e3710fd224e6e052f6bc5420a8f8f03bf41e18;hpb=f0f6da2d30fc005fd0fa126ee1eefd11fe10a604 diff --git a/src/bitboard.h b/src/bitboard.h index 3d629de1..559c70f6 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -2,7 +2,7 @@ Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad - Copyright (C) 2015-2018 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad + Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,22 +107,27 @@ extern Magic BishopMagics[SQUARE_NB]; /// whether a given bit is set in a bitboard, and for setting and clearing bits. inline Bitboard operator&(Bitboard b, Square s) { + assert(s >= SQ_A1 && s <= SQ_H8); return b & SquareBB[s]; } inline Bitboard operator|(Bitboard b, Square s) { + assert(s >= SQ_A1 && s <= SQ_H8); return b | SquareBB[s]; } inline Bitboard operator^(Bitboard b, Square s) { + assert(s >= SQ_A1 && s <= SQ_H8); return b ^ SquareBB[s]; } inline Bitboard& operator|=(Bitboard& b, Square s) { + assert(s >= SQ_A1 && s <= SQ_H8); return b |= SquareBB[s]; } inline Bitboard& operator^=(Bitboard& b, Square s) { + assert(s >= SQ_A1 && s <= SQ_H8); return b ^= SquareBB[s]; } @@ -150,23 +155,13 @@ inline Bitboard file_bb(Square s) { } -/// make_bitboard() returns a bitboard from a list of squares - -constexpr Bitboard make_bitboard() { return 0; } - -template -constexpr Bitboard make_bitboard(Square s, Squares... squares) { - return (1ULL << s) | make_bitboard(squares...); -} - - /// shift() moves a bitboard one step along direction D (mainly for pawns) template constexpr Bitboard shift(Bitboard b) { return D == NORTH ? b << 8 : D == SOUTH ? b >> 8 : D == EAST ? (b & ~FileHBB) << 1 : D == WEST ? (b & ~FileABB) >> 1 - : D == NORTH_EAST ? (b & ~FileHBB) << 9 : D == NORTH_WEST ? (b & ~FileABB) << 7 + : D == NORTH_EAST ? (b & ~FileHBB) << 9 : D == NORTH_WEST ? (b & ~FileABB) << 7 : D == SOUTH_EAST ? (b & ~FileHBB) >> 7 : D == SOUTH_WEST ? (b & ~FileABB) >> 9 : 0; }