Change initialization of some bitboards
authorMarco Costalba <mcostalba@gmail.com>
Tue, 8 Mar 2011 13:38:17 +0000 (14:38 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 8 Mar 2011 18:44:19 +0000 (19:44 +0100)
No functional change.

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

index bc05bfa070c7d9d4afd7dba717443eaa957208e6..54cc94fa7d04525390ff3e66094fff51b2adff69 100644 (file)
@@ -156,51 +156,6 @@ const int RShift[64] = {
 
 #endif // defined(IS_64BIT)
 
 
 #endif // defined(IS_64BIT)
 
-static const Bitboard DarkSquaresBB  = 0xAA55AA55AA55AA55ULL;
-
-const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, ~DarkSquaresBB };
-
-const Bitboard FileBB[8] = {
-  FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
-};
-
-const Bitboard NeighboringFilesBB[8] = {
-  FileBBB, FileABB|FileCBB, FileBBB|FileDBB, FileCBB|FileEBB,
-  FileDBB|FileFBB, FileEBB|FileGBB, FileFBB|FileHBB, FileGBB
-};
-
-const Bitboard ThisAndNeighboringFilesBB[8] = {
-  FileABB|FileBBB, FileABB|FileBBB|FileCBB,
-  FileBBB|FileCBB|FileDBB, FileCBB|FileDBB|FileEBB,
-  FileDBB|FileEBB|FileFBB, FileEBB|FileFBB|FileGBB,
-  FileFBB|FileGBB|FileHBB, FileGBB|FileHBB
-};
-
-const Bitboard RankBB[8] = {
-  Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
-};
-
-const Bitboard InFrontBB[2][8] = {
-  { Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
-    Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
-    Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
-    Rank5BB | Rank6BB | Rank7BB | Rank8BB,
-    Rank6BB | Rank7BB | Rank8BB,
-    Rank7BB | Rank8BB,
-    Rank8BB,
-    EmptyBoardBB
-  },
-  { EmptyBoardBB,
-    Rank1BB,
-    Rank2BB | Rank1BB,
-    Rank3BB | Rank2BB | Rank1BB,
-    Rank4BB | Rank3BB | Rank2BB | Rank1BB,
-    Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
-    Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
-    Rank7BB | Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB
-  }
-};
-
 // Global bitboards definitions with static storage duration are
 // automatically set to zero before enter main().
 Bitboard RMask[64];
 // Global bitboards definitions with static storage duration are
 // automatically set to zero before enter main().
 Bitboard RMask[64];
@@ -214,9 +169,14 @@ Bitboard BAttacks[0x1480];
 Bitboard SetMaskBB[65];
 Bitboard ClearMaskBB[65];
 
 Bitboard SetMaskBB[65];
 Bitboard ClearMaskBB[65];
 
+Bitboard SquaresByColorBB[2];
+Bitboard FileBB[8];
+Bitboard RankBB[8];
+Bitboard NeighboringFilesBB[8];
+Bitboard ThisAndNeighboringFilesBB[8];
+Bitboard InFrontBB[2][8];
 Bitboard NonSlidingAttacksBB[16][64];
 Bitboard BetweenBB[64][64];
 Bitboard NonSlidingAttacksBB[16][64];
 Bitboard BetweenBB[64][64];
-
 Bitboard SquaresInFrontMask[2][64];
 Bitboard PassedPawnMask[2][64];
 Bitboard AttackSpanMask[2][64];
 Bitboard SquaresInFrontMask[2][64];
 Bitboard PassedPawnMask[2][64];
 Bitboard AttackSpanMask[2][64];
@@ -363,6 +323,30 @@ namespace {
 
   void init_masks() {
 
 
   void init_masks() {
 
+    SquaresByColorBB[DARK]  =  0xAA55AA55AA55AA55ULL;
+    SquaresByColorBB[LIGHT] = ~SquaresByColorBB[DARK];
+
+    FileBB[FILE_A] = FileABB;
+    RankBB[RANK_1] = Rank1BB;
+
+    for (File f = FILE_B; f <= FILE_H; f++)
+    {
+        FileBB[f] = FileBB[f - 1] << 1;
+        RankBB[f] = RankBB[f - 1] << 8;
+    }
+
+    for (File f = FILE_A; f <= FILE_H; f++)
+    {
+        NeighboringFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
+        ThisAndNeighboringFilesBB[f] = FileBB[f] | NeighboringFilesBB[f];
+    }
+
+    for (Rank rw = RANK_7, rb = RANK_1; rw >= RANK_1; rw--, rb++)
+    {
+        InFrontBB[WHITE][rw] = InFrontBB[WHITE][rw + 1] | RankBB[rw + 1];
+        InFrontBB[BLACK][rb] = InFrontBB[BLACK][rb - 1] | RankBB[rb - 1];
+    }
+
     SetMaskBB[SQ_NONE] = EmptyBoardBB;
     ClearMaskBB[SQ_NONE] = ~SetMaskBB[SQ_NONE];
 
     SetMaskBB[SQ_NONE] = EmptyBoardBB;
     ClearMaskBB[SQ_NONE] = ~SetMaskBB[SQ_NONE];
 
index b962226bfb9e5048f950a2dd954622e48db28f7d..7f0fdb5a86a3029bd2f677b9f772a591ce79c3aa 100644 (file)
@@ -43,12 +43,12 @@ const Bitboard Rank6BB = Rank1BB << (8 * 5);
 const Bitboard Rank7BB = Rank1BB << (8 * 6);
 const Bitboard Rank8BB = Rank1BB << (8 * 7);
 
 const Bitboard Rank7BB = Rank1BB << (8 * 6);
 const Bitboard Rank8BB = Rank1BB << (8 * 7);
 
-extern const Bitboard SquaresByColorBB[2];
-extern const Bitboard FileBB[8];
-extern const Bitboard NeighboringFilesBB[8];
-extern const Bitboard ThisAndNeighboringFilesBB[8];
-extern const Bitboard RankBB[8];
-extern const Bitboard InFrontBB[2][8];
+extern Bitboard SquaresByColorBB[2];
+extern Bitboard FileBB[8];
+extern Bitboard NeighboringFilesBB[8];
+extern Bitboard ThisAndNeighboringFilesBB[8];
+extern Bitboard RankBB[8];
+extern Bitboard InFrontBB[2][8];
 
 extern Bitboard SetMaskBB[65];
 extern Bitboard ClearMaskBB[65];
 
 extern Bitboard SetMaskBB[65];
 extern Bitboard ClearMaskBB[65];