]> git.sesse.net Git - stockfish/commitdiff
Another (final?) attempt at squares_delta()
authorMarco Costalba <mcostalba@gmail.com>
Sun, 2 Jan 2011 10:45:03 +0000 (11:45 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 2 Jan 2011 10:52:51 +0000 (11:52 +0100)
This time I have removed the function alltogether !

Sorry to work above a patch of UncombedCoconut (Justin Blanchard)
but I couldn't resist ;-)

No functional change.

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

index 23ff18172834720e0538b309cf3b1fb08294a080..1e07c8ce32bda3cc2eba58cd98a7aec83fcc2360 100644 (file)
@@ -248,7 +248,6 @@ namespace {
   void init_attacks();
   void init_between_bitboards();
   void init_pseudo_attacks();
-  SquareDelta ray_direction(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,31 +453,27 @@ namespace {
     return result;
   }
 
-  SquareDelta ray_direction(Square orig, Square dest) {
-
-    int df = file_distance(orig, dest);
-    int dr = rank_distance(orig, dest);
-
-    if (orig != dest && (!df || !dr || df == dr))
-        return SquareDelta(dest - orig) / Max(df, dr);
-
-    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 = ray_direction(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);
+            }
       }
   }