]> git.sesse.net Git - stockfish/commitdiff
Retire RelativeRankBB[]
authorMarco Costalba <mcostalba@gmail.com>
Wed, 19 Jan 2011 11:20:06 +0000 (12:20 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 19 Jan 2011 12:33:38 +0000 (13:33 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/bitboard.h
src/endgame.cpp
src/position.h
src/square.h

index 8c1be7390a14a02a04dba241710a27c6550123a1..57f47094c67a6fa8f5015167dcdd75747beaa196 100644 (file)
@@ -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,
index 6e37395241ad538a3a256f123f4a508af2755e8a..90deacd9e88fc1fe268b284730252051b0572e87 100644 (file)
@@ -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,
index e0efd0e665271b75f2fc6bab5b824b97f843de89..0d9d3c26c216b2fbeb394b5a887c21530ac90425 100644 (file)
@@ -446,8 +446,8 @@ ScaleFactor ScalingFunction<KQKRPs>::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<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
   {
       Square rsq = pos.piece_list(weakerSide, ROOK, 0);
index 23d3094fed32630772405ceeeab4404f5095782c..4305759b0cf751c7cfa0f1eaaea3d90fffade9fa 100644 (file)
@@ -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 {
index 46456d0677c88fed74609a2a9654e68245ba830a..5e474f0f4a7574b0a04e3484664f0168ac463abf 100644 (file)
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
 #if !defined(SQUARE_H_INCLUDED)
 #define SQUARE_H_INCLUDED
 
-////
-//// Includes
-////
-
 #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,
@@ -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) {