Introduce distance() and unify some API

Original work by Lucas.

No functional change.
This commit is contained in:
Marco Costalba
2014-11-08 14:04:14 +01:00
parent 8631b08d97
commit 6fb0a1bc40
7 changed files with 63 additions and 69 deletions

View 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;