From 4f3fe89fb6e957fd971a76080687ba358ec27603 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 19 Jan 2011 12:20:06 +0100 Subject: [PATCH] Retire RelativeRankBB[] No functional change. Signed-off-by: Marco Costalba --- src/bitboard.cpp | 10 ++-------- src/bitboard.h | 12 ------------ src/endgame.cpp | 4 ++-- src/position.h | 2 +- src/square.h | 29 +++++++---------------------- 5 files changed, 12 insertions(+), 45 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 8c1be739..57f47094 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -162,10 +162,9 @@ const int RShift[64] = { #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 @@ -187,11 +186,6 @@ const Bitboard RankBB[8] = { 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, diff --git a/src/bitboard.h b/src/bitboard.h index 6e373952..90deacd9 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -50,7 +50,6 @@ extern const Bitboard FileBB[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]; @@ -154,17 +153,6 @@ inline Bitboard this_and_neighboring_files_bb(Square s) { } -/// 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, diff --git a/src/endgame.cpp b/src/endgame.cpp index e0efd0e6..0d9d3c26 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -446,8 +446,8 @@ ScaleFactor ScalingFunction::apply(const Position& pos) const { 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(kingSq) & pos.pieces(PAWN, weakerSide))) { Square rsq = pos.piece_list(weakerSide, ROOK, 0); diff --git a/src/position.h b/src/position.h index 23d3094f..4305759b 100644 --- a/src/position.h +++ b/src/position.h @@ -544,7 +544,7 @@ inline bool Position::opposite_colored_bishops() 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 { diff --git a/src/square.h b/src/square.h index 46456d06..5e474f0f 100644 --- a/src/square.h +++ b/src/square.h @@ -17,25 +17,15 @@ along with this program. If not, see . */ - #if !defined(SQUARE_H_INCLUDED) #define SQUARE_H_INCLUDED -//// -//// Includes -//// - #include // for abs() #include #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, @@ -49,11 +39,11 @@ enum Square { }; enum File { - 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 }; enum Rank { - 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 }; enum SquareDelta { @@ -73,18 +63,9 @@ ENABLE_OPERATORS_ON(File) ENABLE_OPERATORS_ON(Rank) ENABLE_OPERATORS_ON(SquareDelta) - -//// -//// Constants -//// - 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); } @@ -114,8 +95,12 @@ inline Square relative_square(Color c, Square s) { 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) { - return square_rank(relative_square(c, s)); + return relative_rank(c, square_rank(s)); } inline SquareColor square_color(Square s) { -- 2.39.2