Introduce distance() and unify some API
[stockfish] / src / bitboard.cpp
index aa65d7f812c2814744a48f26f419572d07712429..5a4c8b6b82fd6fe5b3330fbbd1d3160ad9352672 100644 (file)
@@ -177,7 +177,7 @@ void Bitboards::init() {
       for (Square s2 = SQ_A1; s2 <= SQ_H8; ++s2)
           if (s1 != s2)
           {
-              SquareDistance[s1][s2] = std::max(file_distance(s1, s2), rank_distance(s1, s2));
+              SquareDistance[s1][s2] = std::max(distance<File>(s1, s2), distance<Rank>(s1, s2));
               DistanceRingsBB[s1][SquareDistance[s1][s2] - 1] |= s2;
           }
 
@@ -191,7 +191,7 @@ void Bitboards::init() {
               {
                   Square to = s + Square(c == WHITE ? steps[pt][i] : -steps[pt][i]);
 
-                  if (is_ok(to) && square_distance(s, to) < 3)
+                  if (is_ok(to) && distance(s, to) < 3)
                       StepAttacksBB[make_piece(c, pt)][s] |= to;
               }
 
@@ -229,7 +229,7 @@ namespace {
 
     for (int i = 0; i < 4; ++i)
         for (Square s = sq + deltas[i];
-             is_ok(s) && square_distance(s, s - deltas[i]) == 1;
+             is_ok(s) && distance(s, s - deltas[i]) == 1;
              s += deltas[i])
         {
             attack |= s;