mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Clarify the mapping of files to queenside
This patch replaces the obscure expressions mapping files ABCDEFGH to ABCDDCBA by explicite calls to an auxiliary function: old: f = min(f, ~f) new: f = map_to_queenside(f) We used the Golbolt web site (https://godbolt.org) to check that the current code for the auxiliary function is optimal. STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 30292 W: 6756 L: 6651 D: 16885 http://tests.stockfishchess.org/tests/view/5d8676720ebc5971531d6aa1 Achieved with a bit of help from Sopel97, snicolet and vondele, thanks everyone! Closes https://github.com/official-stockfish/Stockfish/pull/2325 No functional change
This commit is contained in:
committed by
Stéphane Nicolet
parent
defa1ccaa9
commit
d232a4ae68
@@ -43,6 +43,7 @@
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Disable some silly and noisy warning from MSVC compiler
|
||||
@@ -358,14 +359,14 @@ constexpr Square operator~(Square s) {
|
||||
return Square(s ^ SQ_A8); // Vertical flip SQ_A1 -> SQ_A8
|
||||
}
|
||||
|
||||
constexpr File operator~(File f) {
|
||||
return File(f ^ FILE_H); // Horizontal flip FILE_A -> FILE_H
|
||||
}
|
||||
|
||||
constexpr Piece operator~(Piece pc) {
|
||||
return Piece(pc ^ 8); // Swap color of piece B_KNIGHT -> W_KNIGHT
|
||||
}
|
||||
|
||||
inline File map_to_queenside(File f) {
|
||||
return std::min(f, File(FILE_H - f)); // Map files ABCDEFGH to files ABCDDCBA
|
||||
}
|
||||
|
||||
constexpr CastlingRights operator&(Color c, CastlingRights cr) {
|
||||
return CastlingRights((c == WHITE ? WHITE_CASTLING : BLACK_CASTLING) & cr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user