]> git.sesse.net Git - stockfish/blobdiff - src/bitboard.cpp
Restore development version
[stockfish] / src / bitboard.cpp
index 9d9a16e8ba3614f51ff55eec3f14f813bd0d6e24..1e07c8ce32bda3cc2eba58cd98a7aec83fcc2360 100644 (file)
@@ -248,7 +248,6 @@ namespace {
   void init_attacks();
   void init_between_bitboards();
   void init_pseudo_attacks();
-  SquareDelta squares_delta(Square orig, Square dest);
   Bitboard index_to_bitboard(int index, Bitboard mask);
   Bitboard sliding_attacks(int sq, Bitboard block, int dirs, int deltas[][2],
                            int fmin, int fmax, int rmin, int rmax);
@@ -288,10 +287,10 @@ void init_bitboards() {
 
   init_masks();
   init_attacks();
-  init_between_bitboards();
   init_sliding_attacks(RAttacks, RAttackIndex, RMask, RShift, RMult, rookDeltas);
   init_sliding_attacks(BAttacks, BAttackIndex, BMask, BShift, BMult, bishopDeltas);
   init_pseudo_attacks();
+  init_between_bitboards();
 }
 
 
@@ -454,40 +453,27 @@ namespace {
     return result;
   }
 
-  SquareDelta squares_delta(Square orig, Square dest) {
-
-    const SquareDelta deltas[] = { DELTA_N, DELTA_NE, DELTA_E, DELTA_SE,
-                                   DELTA_S, DELTA_SW, DELTA_W, DELTA_NW };
-
-    for (int idx = 0; idx < 8; idx++)
-    {
-        Square s = orig + deltas[idx];
-
-        while (square_is_ok(s) && square_distance(s, s - deltas[idx]) == 1)
-        {
-            if (s == dest)
-                return deltas[idx];
-
-            s += deltas[idx];
-        }
-    }
-    return DELTA_NONE;
-  }
-
   void init_between_bitboards() {
 
     Square s1, s2, s3;
     SquareDelta d;
+    int f, r;
 
     for (s1 = SQ_A1; s1 <= SQ_H8; s1++)
         for (s2 = SQ_A1; s2 <= SQ_H8; s2++)
         {
             BetweenBB[s1][s2] = EmptyBoardBB;
-            d = squares_delta(s1, s2);
 
-            if (d != DELTA_NONE)
+            if (bit_is_set(QueenPseudoAttacks[s1], s2))
+            {
+                f = file_distance(s1, s2);
+                r = rank_distance(s1, s2);
+
+                d = SquareDelta(s2 - s1) / Max(f, r);
+
                 for (s3 = s1 + d; s3 != s2; s3 += d)
                     set_bit(&(BetweenBB[s1][s2]), s3);
+            }
       }
   }