mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 02:27:00 +08:00
Mark all compile-time constants as constexpr.
To more clearly distinguish them from "const" local variables, this patch defines compile-time local constants as constexpr. This is consistent with the definition of PvNode as constexpr in search() and qsearch(). It also makes the code more robust, since the compiler will now check that those constants are indeed compile-time constants. We can go even one step further and define all the evaluation and search compile-time constants as constexpr. In generate_castling() I replaced "K" with "step", since K was incorrectly capitalised (in the Chess960 case). In timeman.cpp I had to make the non-local constants MaxRatio and StealRatio constepxr, since otherwise gcc would complain when calculating TMaxRatio and TStealRatio. (Strangely, I did not have to make Is64Bit constexpr even though it is used in ucioption.cpp in the calculation of constexpr MaxHashMB.) I have renamed PieceCount to pieceCount in material.h, since the values of the array are not compile-time constants. Some compile-time constants in tbprobe.cpp were overlooked. Sides and MaxFile are not compile-time constants, so were renamed to sides and maxFile. Non-functional change.
This commit is contained in:
committed by
Stéphane Nicolet
parent
350dff4464
commit
759b3c79cf
@@ -29,7 +29,7 @@
|
||||
namespace {
|
||||
|
||||
// There are 24 possible pawn squares: the first 4 files and ranks from 2 to 7
|
||||
const unsigned MAX_INDEX = 2*24*64*64; // stm * psq * wksq * bksq = 196608
|
||||
constexpr unsigned MAX_INDEX = 2*24*64*64; // stm * psq * wksq * bksq = 196608
|
||||
|
||||
// Each uint32_t stores results of 32 positions, one per bit
|
||||
uint32_t KPKBitbase[MAX_INDEX / 32];
|
||||
@@ -152,9 +152,9 @@ namespace {
|
||||
// as WIN, the position is classified as WIN, otherwise the current position is
|
||||
// classified as UNKNOWN.
|
||||
|
||||
const Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||
const Result Good = (Us == WHITE ? WIN : DRAW);
|
||||
const Result Bad = (Us == WHITE ? DRAW : WIN);
|
||||
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||
constexpr Result Good = (Us == WHITE ? WIN : DRAW);
|
||||
constexpr Result Bad = (Us == WHITE ? DRAW : WIN);
|
||||
|
||||
Result r = INVALID;
|
||||
Bitboard b = PseudoAttacks[KING][ksq[Us]];
|
||||
|
||||
Reference in New Issue
Block a user