mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 10:36:26 +08:00
Simplify distance (#2109)
Only called with Squares as argument, so remove unused variants. As this is just syntax changes, only verified bench at high depth. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
c4fc00ec49
commit
f21b503982
@@ -237,15 +237,13 @@ inline bool aligned(Square s1, Square s2, Square s3) {
|
||||
|
||||
|
||||
/// distance() functions return the distance between x and y, defined as the
|
||||
/// number of steps for a king in x to reach y. Works with squares, ranks, files.
|
||||
/// number of steps for a king in x to reach y.
|
||||
|
||||
template<typename T> inline int distance(T x, T y) { return std::abs(x - y); }
|
||||
template<typename T1 = Square> inline int distance(Square x, Square y);
|
||||
template<> inline int distance<File>(Square x, Square y) { return std::abs(file_of(x) - file_of(y)); }
|
||||
template<> inline int distance<Rank>(Square x, Square y) { return std::abs(rank_of(x) - rank_of(y)); }
|
||||
template<> inline int distance<Square>(Square x, Square y) { return SquareDistance[x][y]; }
|
||||
|
||||
template<typename T1, typename T2> inline int distance(T2 x, T2 y);
|
||||
template<> inline int distance<File>(Square x, Square y) { return distance(file_of(x), file_of(y)); }
|
||||
template<> inline int distance<Rank>(Square x, Square y) { return distance(rank_of(x), rank_of(y)); }
|
||||
|
||||
template<class T> constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
|
||||
return v < lo ? lo : v > hi ? hi : v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user