No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
#endif // defined(IS_64BIT)
#endif // defined(IS_64BIT)
-const Bitboard LightSquaresBB = 0x55AA55AA55AA55AAULL;
-const Bitboard DarkSquaresBB = 0xAA55AA55AA55AA55ULL;
+static const Bitboard DarkSquaresBB = 0xAA55AA55AA55AA55ULL;
-const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, LightSquaresBB };
+const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, ~DarkSquaresBB };
const Bitboard FileBB[8] = {
FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
const Bitboard FileBB[8] = {
FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
};
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
};
-const Bitboard RelativeRankBB[2][8] = {
- { Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB },
- { Rank8BB, Rank7BB, Rank6BB, Rank5BB, Rank4BB, Rank3BB, Rank2BB, Rank1BB }
-};
-
const Bitboard InFrontBB[2][8] = {
{ Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
const Bitboard InFrontBB[2][8] = {
{ Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
extern const Bitboard NeighboringFilesBB[8];
extern const Bitboard ThisAndNeighboringFilesBB[8];
extern const Bitboard RankBB[8];
extern const Bitboard NeighboringFilesBB[8];
extern const Bitboard ThisAndNeighboringFilesBB[8];
extern const Bitboard RankBB[8];
-extern const Bitboard RelativeRankBB[2][8];
extern const Bitboard InFrontBB[2][8];
extern Bitboard SetMaskBB[65];
extern const Bitboard InFrontBB[2][8];
extern Bitboard SetMaskBB[65];
-/// relative_rank_bb() takes a color and a rank as input, and returns a bitboard
-/// representing all squares on the given rank from the given color's point of
-/// view. For instance, relative_rank_bb(WHITE, 7) gives all squares on the
-/// 7th rank, while relative_rank_bb(BLACK, 7) gives all squares on the 2nd
-/// rank.
-
-inline Bitboard relative_rank_bb(Color c, Rank r) {
- return RelativeRankBB[c][r];
-}
-
-
/// in_front_bb() takes a color and a rank or square as input, and returns a
/// bitboard representing all the squares on all ranks in front of the rank
/// (or square), from the given color's point of view. For instance,
/// in_front_bb() takes a color and a rank or square as input, and returns a
/// bitboard representing all the squares on all ranks in front of the rank
/// (or square), from the given color's point of view. For instance,
Square kingSq = pos.king_square(weakerSide);
if ( relative_rank(weakerSide, kingSq) <= RANK_2
&& relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4
Square kingSq = pos.king_square(weakerSide);
if ( relative_rank(weakerSide, kingSq) <= RANK_2
&& relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4
- && (pos.pieces(ROOK, weakerSide) & relative_rank_bb(weakerSide, RANK_3))
- && (pos.pieces(PAWN, weakerSide) & relative_rank_bb(weakerSide, RANK_2))
+ && (pos.pieces(ROOK, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_3)))
+ && (pos.pieces(PAWN, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_2)))
&& (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
{
Square rsq = pos.piece_list(weakerSide, ROOK, 0);
&& (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
{
Square rsq = pos.piece_list(weakerSide, ROOK, 0);
}
inline bool Position::has_pawn_on_7th(Color c) const {
}
inline bool Position::has_pawn_on_7th(Color c) const {
- return pieces(PAWN, c) & relative_rank_bb(c, RANK_7);
+ return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7));
}
inline bool Position::is_chess960() const {
}
inline bool Position::is_chess960() const {
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(SQUARE_H_INCLUDED)
#define SQUARE_H_INCLUDED
#if !defined(SQUARE_H_INCLUDED)
#define SQUARE_H_INCLUDED
-////
-//// Includes
-////
-
#include <cstdlib> // for abs()
#include <string>
#include "color.h"
#include "misc.h"
#include <cstdlib> // for abs()
#include <string>
#include "color.h"
#include "misc.h"
-
-////
-//// Types
-////
-
enum Square {
SQ_A1, SQ_B1, SQ_C1, SQ_D1, SQ_E1, SQ_F1, SQ_G1, SQ_H1,
SQ_A2, SQ_B2, SQ_C2, SQ_D2, SQ_E2, SQ_F2, SQ_G2, SQ_H2,
enum Square {
SQ_A1, SQ_B1, SQ_C1, SQ_D1, SQ_E1, SQ_F1, SQ_G1, SQ_H1,
SQ_A2, SQ_B2, SQ_C2, SQ_D2, SQ_E2, SQ_F2, SQ_G2, SQ_H2,
- FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H, FILE_NONE
+ FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
- RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8, RANK_NONE
+ RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
ENABLE_OPERATORS_ON(Rank)
ENABLE_OPERATORS_ON(SquareDelta)
ENABLE_OPERATORS_ON(Rank)
ENABLE_OPERATORS_ON(SquareDelta)
-
-////
-//// Constants
-////
-
const int FlipMask = 56;
const int FlopMask = 7;
const int FlipMask = 56;
const int FlopMask = 7;
-////
-//// Inline functions
-////
-
inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); }
inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); }
inline Square operator- (Square x, SquareDelta i) { return x - Square(i); }
inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); }
inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); }
inline Square operator- (Square x, SquareDelta i) { return x - Square(i); }
return Square(int(s) ^ (int(c) * FlipMask));
}
return Square(int(s) ^ (int(c) * FlipMask));
}
+inline Rank relative_rank(Color c, Rank r) {
+ return Rank(int(r) ^ (int(c) * 7));
+}
+
inline Rank relative_rank(Color c, Square s) {
inline Rank relative_rank(Color c, Square s) {
- return square_rank(relative_square(c, s));
+ return relative_rank(c, square_rank(s));
}
inline SquareColor square_color(Square s) {
}
inline SquareColor square_color(Square s) {