X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=e1c31dd7c5fd1525dc61712de06fa55cf760ac7b;hp=7ae1effd9487f036407f3429c8a5047ec6f52023;hb=3300517ecb75df265489d2a9841e4fce2414fd09;hpb=06e0134cbc9bcf16d01738c491ec53869a5205b6 diff --git a/src/bitboard.h b/src/bitboard.h index 7ae1effd..e1c31dd7 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 @@ -65,7 +65,6 @@ extern int SquareDistance[SQUARE_NB][SQUARE_NB]; extern Bitboard SquareBB[SQUARE_NB]; extern Bitboard FileBB[FILE_NB]; extern Bitboard RankBB[RANK_NB]; -extern Bitboard AdjacentFilesBB[FILE_NB]; extern Bitboard ForwardRanksBB[COLOR_NB][RANK_NB]; extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; extern Bitboard LineBB[SQUARE_NB][SQUARE_NB]; @@ -135,6 +134,10 @@ constexpr bool more_than_one(Bitboard b) { return b & (b - 1); } +inline bool opposite_colors(Square s1, Square s2) { + return bool(DarkSquares & s1) != bool(DarkSquares & s2); +} + /// rank_bb() and file_bb() return a bitboard representing all the squares on /// the given file or rank. @@ -155,16 +158,6 @@ 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 @@ -187,11 +180,21 @@ constexpr Bitboard pawn_attacks_bb(Bitboard b) { } +/// double_pawn_attacks_bb() returns the pawn attacks for the given color +/// from the squares in the given bitboard. + +template +constexpr Bitboard double_pawn_attacks_bb(Bitboard b) { + return C == WHITE ? shift(b) & shift(b) + : shift(b) & shift(b); +} + + /// adjacent_files_bb() returns a bitboard representing all the squares on the /// adjacent files of the given one. inline Bitboard adjacent_files_bb(File f) { - return AdjacentFilesBB[f]; + return shift(FileBB[f]) | shift(FileBB[f]); }