]> git.sesse.net Git - stockfish/blobdiff - src/bitboard.cpp
Restore development version
[stockfish] / src / bitboard.cpp
index 43054cfb9f54532f5329f5ea45a6f79700bb5c6f..1e07c8ce32bda3cc2eba58cd98a7aec83fcc2360 100644 (file)
@@ -287,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();
 }
 
 
@@ -455,26 +455,25 @@ namespace {
 
   void init_between_bitboards() {
 
-    const SquareDelta directionToDelta[] = {
-        DELTA_E, DELTA_N, DELTA_NE, DELTA_NW, DELTA_W, DELTA_S, DELTA_SW, DELTA_SE
-    };
-
     Square s1, s2, s3;
-    Direction d;
+    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 = direction_between_squares(s1, s2);
 
-            if (d == DIR_NONE)
-                continue;
+            if (bit_is_set(QueenPseudoAttacks[s1], s2))
+            {
+                f = file_distance(s1, s2);
+                r = rank_distance(s1, s2);
 
-            SquareDelta sd = directionToDelta[s2 > s1 ? d : d + 4];
+                d = SquareDelta(s2 - s1) / Max(f, r);
 
-            for (s3 = s1 + sd; s3 != s2; s3 += sd)
-                set_bit(&(BetweenBB[s1][s2]), s3);
+                for (s3 = s1 + d; s3 != s2; s3 += d)
+                    set_bit(&(BetweenBB[s1][s2]), s3);
+            }
       }
   }