mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Introduce distance() and unify some API
Original work by Lucas. No functional change.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user