mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 08:37:44 +00:00
Consolidate Square Flipping
Add a flip_rank() and flip_file() so that all of the square flipping can be consolidated.
STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 57234 W: 11064 L: 10969 D: 35201
Ptnml(0-2): 822, 6562, 13801, 6563, 869
http://tests.stockfishchess.org/tests/view/5e5d2f2aafe6254521f2ffaa
closes https://github.com/official-stockfish/Stockfish/pull/2568
No functional change.
This commit is contained in:
committed by
Joost VandeVondele
parent
c6839a2615
commit
960d59d541
@@ -66,7 +66,6 @@ enum TBType { KEY, WDL, DTZ }; // Used as template parameter
|
||||
enum TBFlag { STM = 1, Mapped = 2, WinPlies = 4, LossPlies = 8, Wide = 16, SingleValue = 128 };
|
||||
|
||||
inline WDLScore operator-(WDLScore d) { return WDLScore(-int(d)); }
|
||||
inline Square operator^=(Square& s, int i) { return s = Square(int(s) ^ i); }
|
||||
inline Square operator^(Square s, int i) { return Square(int(s) ^ i); }
|
||||
|
||||
const std::string PieceToChar = " PNBRQK pnbrqk";
|
||||
@@ -743,7 +742,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
||||
// the triangle A1-D1-D4.
|
||||
if (file_of(squares[0]) > FILE_D)
|
||||
for (int i = 0; i < size; ++i)
|
||||
squares[i] ^= 7; // Horizontal flip: SQ_H1 -> SQ_A1
|
||||
squares[i] = flip_file(squares[i]);
|
||||
|
||||
// Encode leading pawns starting with the one with minimum MapPawns[] and
|
||||
// proceeding in ascending order.
|
||||
@@ -762,7 +761,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
||||
// piece is below RANK_5.
|
||||
if (rank_of(squares[0]) > RANK_4)
|
||||
for (int i = 0; i < size; ++i)
|
||||
squares[i] ^= SQ_A8; // Vertical flip: SQ_A8 -> SQ_A1
|
||||
squares[i] = flip_rank(squares[i]);
|
||||
|
||||
// Look for the first piece of the leading group not on the A1-D4 diagonal
|
||||
// and ensure it is mapped below the diagonal.
|
||||
@@ -1344,7 +1343,7 @@ void Tablebases::init(const std::string& paths) {
|
||||
if (leadPawnsCnt == 1)
|
||||
{
|
||||
MapPawns[sq] = availableSquares--;
|
||||
MapPawns[sq ^ 7] = availableSquares--; // Horizontal flip
|
||||
MapPawns[flip_file(sq)] = availableSquares--;
|
||||
}
|
||||
LeadPawnIdx[leadPawnsCnt][sq] = idx;
|
||||
idx += Binomial[leadPawnsCnt - 1][MapPawns[sq]];
|
||||
|
||||
Reference in New Issue
Block a user