mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Make casting styles consistent
Make casting styles consistent with the rest of the code. closes https://github.com/official-stockfish/Stockfish/pull/4793 No functional change
This commit is contained in:
parent
952740b36c
commit
fce4cc1829
11 changed files with 56 additions and 56 deletions
|
@ -264,7 +264,7 @@ inline int popcount(Bitboard b) {
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
|
||||||
return (int)_mm_popcnt_u64(b);
|
return int(_mm_popcnt_u64(b));
|
||||||
|
|
||||||
#else // Assumed gcc or compatible compiler
|
#else // Assumed gcc or compatible compiler
|
||||||
|
|
||||||
|
|
24
src/misc.cpp
24
src/misc.cpp
|
@ -85,7 +85,7 @@ struct Tie: public std::streambuf { // MSVC requires split streambuf for cin and
|
||||||
Tie(std::streambuf* b, std::streambuf* l) : buf(b), logBuf(l) {}
|
Tie(std::streambuf* b, std::streambuf* l) : buf(b), logBuf(l) {}
|
||||||
|
|
||||||
int sync() override { return logBuf->pubsync(), buf->pubsync(); }
|
int sync() override { return logBuf->pubsync(), buf->pubsync(); }
|
||||||
int overflow(int c) override { return log(buf->sputc((char)c), "<< "); }
|
int overflow(int c) override { return log(buf->sputc(char(c)), "<< "); }
|
||||||
int underflow() override { return buf->sgetc(); }
|
int underflow() override { return buf->sgetc(); }
|
||||||
int uflow() override { return log(buf->sbumpc(), ">> "); }
|
int uflow() override { return log(buf->sbumpc(), ">> "); }
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ struct Tie: public std::streambuf { // MSVC requires split streambuf for cin and
|
||||||
if (last == '\n')
|
if (last == '\n')
|
||||||
logBuf->sputn(prefix, 3);
|
logBuf->sputn(prefix, 3);
|
||||||
|
|
||||||
return last = logBuf->sputc((char)c);
|
return last = logBuf->sputc(char(c));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,9 +215,9 @@ std::string compiler_info() {
|
||||||
compiler += ")";
|
compiler += ")";
|
||||||
#elif defined(__e2k__) && defined(__LCC__)
|
#elif defined(__e2k__) && defined(__LCC__)
|
||||||
#define dot_ver2(n) \
|
#define dot_ver2(n) \
|
||||||
compiler += (char)'.'; \
|
compiler += char('.'); \
|
||||||
compiler += (char)('0' + (n) / 10); \
|
compiler += char('0' + (n) / 10); \
|
||||||
compiler += (char)('0' + (n) % 10);
|
compiler += char('0' + (n) % 10);
|
||||||
|
|
||||||
compiler += "MCST LCC ";
|
compiler += "MCST LCC ";
|
||||||
compiler += "(version ";
|
compiler += "(version ";
|
||||||
|
@ -498,13 +498,13 @@ static void* aligned_large_pages_alloc_windows([[maybe_unused]] size_t allocSize
|
||||||
if (!hAdvapi32)
|
if (!hAdvapi32)
|
||||||
hAdvapi32 = LoadLibrary(TEXT("advapi32.dll"));
|
hAdvapi32 = LoadLibrary(TEXT("advapi32.dll"));
|
||||||
|
|
||||||
auto fun6 = (fun6_t)(void(*)())GetProcAddress(hAdvapi32, "OpenProcessToken");
|
auto fun6 = fun6_t((void(*)())GetProcAddress(hAdvapi32, "OpenProcessToken"));
|
||||||
if (!fun6)
|
if (!fun6)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto fun7 = (fun7_t)(void(*)())GetProcAddress(hAdvapi32, "LookupPrivilegeValueA");
|
auto fun7 = fun7_t((void(*)())GetProcAddress(hAdvapi32, "LookupPrivilegeValueA"));
|
||||||
if (!fun7)
|
if (!fun7)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto fun8 = (fun8_t)(void(*)())GetProcAddress(hAdvapi32, "AdjustTokenPrivileges");
|
auto fun8 = fun8_t((void(*)())GetProcAddress(hAdvapi32, "AdjustTokenPrivileges"));
|
||||||
if (!fun8)
|
if (!fun8)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -699,10 +699,10 @@ void bindThisThread(size_t idx) {
|
||||||
|
|
||||||
// Early exit if the needed API are not available at runtime
|
// Early exit if the needed API are not available at runtime
|
||||||
HMODULE k32 = GetModuleHandle(TEXT("Kernel32.dll"));
|
HMODULE k32 = GetModuleHandle(TEXT("Kernel32.dll"));
|
||||||
auto fun2 = (fun2_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMaskEx");
|
auto fun2 = fun2_t((void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMaskEx"));
|
||||||
auto fun3 = (fun3_t)(void(*)())GetProcAddress(k32, "SetThreadGroupAffinity");
|
auto fun3 = fun3_t((void(*)())GetProcAddress(k32, "SetThreadGroupAffinity"));
|
||||||
auto fun4 = (fun4_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMask2");
|
auto fun4 = fun4_t((void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMask2"));
|
||||||
auto fun5 = (fun5_t)(void(*)())GetProcAddress(k32, "GetMaximumProcessorGroupCount");
|
auto fun5 = fun5_t((void(*)())GetProcAddress(k32, "GetMaximumProcessorGroupCount"));
|
||||||
|
|
||||||
if (!fun2 || !fun3)
|
if (!fun2 || !fun3)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -133,13 +133,13 @@ public:
|
||||||
inline uint64_t mul_hi64(uint64_t a, uint64_t b) {
|
inline uint64_t mul_hi64(uint64_t a, uint64_t b) {
|
||||||
#if defined(__GNUC__) && defined(IS_64BIT)
|
#if defined(__GNUC__) && defined(IS_64BIT)
|
||||||
__extension__ using uint128 = unsigned __int128;
|
__extension__ using uint128 = unsigned __int128;
|
||||||
return ((uint128)a * (uint128)b) >> 64;
|
return (uint128(a) * uint128(b)) >> 64;
|
||||||
#else
|
#else
|
||||||
uint64_t aL = (uint32_t)a, aH = a >> 32;
|
uint64_t aL = uint32_t(a), aH = a >> 32;
|
||||||
uint64_t bL = (uint32_t)b, bH = b >> 32;
|
uint64_t bL = uint32_t(b), bH = b >> 32;
|
||||||
uint64_t c1 = (aL * bL) >> 32;
|
uint64_t c1 = (aL * bL) >> 32;
|
||||||
uint64_t c2 = aH * bL + c1;
|
uint64_t c2 = aH * bL + c1;
|
||||||
uint64_t c3 = aL * bH + (uint32_t)c2;
|
uint64_t c3 = aL * bH + uint32_t(c2);
|
||||||
return aH * bH + (c2 >> 32) + (c3 >> 32);
|
return aH * bH + (c2 >> 32) + (c3 >> 32);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ template<GenType Type>
|
||||||
ExtMove* generate(const Position& pos, ExtMove* moveList) {
|
ExtMove* generate(const Position& pos, ExtMove* moveList) {
|
||||||
|
|
||||||
static_assert(Type != LEGAL, "Unsupported type in generate()");
|
static_assert(Type != LEGAL, "Unsupported type in generate()");
|
||||||
assert((Type == EVASIONS) == (bool)pos.checkers());
|
assert((Type == EVASIONS) == bool(pos.checkers()));
|
||||||
|
|
||||||
Color us = pos.side_to_move();
|
Color us = pos.side_to_move();
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace Stockfish::Eval::NNUE {
|
||||||
if (!Detail::write_parameters(stream, *featureTransformer)) return false;
|
if (!Detail::write_parameters(stream, *featureTransformer)) return false;
|
||||||
for (std::size_t i = 0; i < LayerStacks; ++i)
|
for (std::size_t i = 0; i < LayerStacks; ++i)
|
||||||
if (!Detail::write_parameters(stream, *(network[i]))) return false;
|
if (!Detail::write_parameters(stream, *(network[i]))) return false;
|
||||||
return (bool)stream;
|
return bool(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hint_common_parent_position(const Position& pos) {
|
void hint_common_parent_position(const Position& pos) {
|
||||||
|
@ -281,8 +281,8 @@ namespace Stockfish::Eval::NNUE {
|
||||||
// A lambda to output one box of the board
|
// A lambda to output one box of the board
|
||||||
auto writeSquare = [&board](File file, Rank rank, Piece pc, Value value) {
|
auto writeSquare = [&board](File file, Rank rank, Piece pc, Value value) {
|
||||||
|
|
||||||
const int x = ((int)file) * 8;
|
const int x = int(file) * 8;
|
||||||
const int y = (7 - (int)rank) * 3;
|
const int y = (7 - int(rank)) * 3;
|
||||||
for (int i = 1; i < 8; ++i)
|
for (int i = 1; i < 8; ++i)
|
||||||
board[y][x+i] = board[y+3][x+i] = '-';
|
board[y][x+i] = board[y+3][x+i] = '-';
|
||||||
for (int i = 1; i < 3; ++i)
|
for (int i = 1; i < 3; ++i)
|
||||||
|
|
|
@ -310,7 +310,7 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||||
vec_t sum0 = vec_setzero();
|
vec_t sum0 = vec_setzero();
|
||||||
const auto row0 = reinterpret_cast<const vec_t*>(&weights[0]);
|
const auto row0 = reinterpret_cast<const vec_t*>(&weights[0]);
|
||||||
|
|
||||||
for (int j = 0; j < (int)NumChunks; ++j)
|
for (int j = 0; j < int(NumChunks); ++j)
|
||||||
{
|
{
|
||||||
const vec_t in = inputVector[j];
|
const vec_t in = inputVector[j];
|
||||||
vec_add_dpbusd_32(sum0, in, row0[j]);
|
vec_add_dpbusd_32(sum0, in, row0[j]);
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||||
for (IndexType j = 0; j < InputsPerChunk; ++j)
|
for (IndexType j = 0; j < InputsPerChunk; ++j)
|
||||||
{
|
{
|
||||||
const vec_t inputChunk = inputVector[i * InputsPerChunk + j];
|
const vec_t inputChunk = inputVector[i * InputsPerChunk + j];
|
||||||
nnz |= (unsigned)vec_nnz(inputChunk) << (j * InputSimdWidth);
|
nnz |= unsigned(vec_nnz(inputChunk)) << (j * InputSimdWidth);
|
||||||
}
|
}
|
||||||
for (IndexType j = 0; j < OutputsPerChunk; ++j)
|
for (IndexType j = 0; j < OutputsPerChunk; ++j)
|
||||||
{
|
{
|
||||||
|
|
|
@ -316,7 +316,7 @@ void Thread::search() {
|
||||||
// When playing with strength handicap enable MultiPV search that we will
|
// When playing with strength handicap enable MultiPV search that we will
|
||||||
// use behind-the-scenes to retrieve a set of possible moves.
|
// use behind-the-scenes to retrieve a set of possible moves.
|
||||||
if (skill.enabled())
|
if (skill.enabled())
|
||||||
multiPV = std::max(multiPV, (size_t)4);
|
multiPV = std::max(multiPV, size_t(4));
|
||||||
|
|
||||||
multiPV = std::min(multiPV, rootMoves.size());
|
multiPV = std::min(multiPV, rootMoves.size());
|
||||||
|
|
||||||
|
@ -1861,7 +1861,7 @@ void MainThread::check_time() {
|
||||||
|
|
||||||
if ( (Limits.use_time_management() && (elapsed > Time.maximum() || stopOnPonderhit))
|
if ( (Limits.use_time_management() && (elapsed > Time.maximum() || stopOnPonderhit))
|
||||||
|| (Limits.movetime && elapsed >= Limits.movetime)
|
|| (Limits.movetime && elapsed >= Limits.movetime)
|
||||||
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
|
|| (Limits.nodes && Threads.nodes_searched() >= uint64_t(Limits.nodes)))
|
||||||
Threads.stop = true;
|
Threads.stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1875,7 +1875,7 @@ string UCI::pv(const Position& pos, Depth depth) {
|
||||||
TimePoint elapsed = Time.elapsed() + 1;
|
TimePoint elapsed = Time.elapsed() + 1;
|
||||||
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
|
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
|
||||||
size_t pvIdx = pos.this_thread()->pvIdx;
|
size_t pvIdx = pos.this_thread()->pvIdx;
|
||||||
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
|
size_t multiPV = std::min(size_t(Options["MultiPV"]), rootMoves.size());
|
||||||
uint64_t nodesSearched = Threads.nodes_searched();
|
uint64_t nodesSearched = Threads.nodes_searched();
|
||||||
uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
|
uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ template<typename T, int LE> T number(void* addr)
|
||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
|
|
||||||
if ((uintptr_t)addr & (alignof(T) - 1)) // Unaligned pointer (very rare)
|
if (uintptr_t(addr) & (alignof(T) - 1)) // Unaligned pointer (very rare)
|
||||||
std::memcpy(&v, addr, sizeof(T));
|
std::memcpy(&v, addr, sizeof(T));
|
||||||
else
|
else
|
||||||
v = *((T*)addr);
|
v = *((T*)addr);
|
||||||
|
@ -263,7 +263,7 @@ public:
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
*mapping = (uint64_t)mmap;
|
*mapping = uint64_t(mmap);
|
||||||
*baseAddress = MapViewOfFile(mmap, FILE_MAP_READ, 0, 0, 0);
|
*baseAddress = MapViewOfFile(mmap, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
|
||||||
if (!*baseAddress)
|
if (!*baseAddress)
|
||||||
|
@ -429,7 +429,7 @@ class TBTables {
|
||||||
std::deque<TBTable<DTZ>> dtzTable;
|
std::deque<TBTable<DTZ>> dtzTable;
|
||||||
|
|
||||||
void insert(Key key, TBTable<WDL>* wdl, TBTable<DTZ>* dtz) {
|
void insert(Key key, TBTable<WDL>* wdl, TBTable<DTZ>* dtz) {
|
||||||
uint32_t homeBucket = (uint32_t)key & (Size - 1);
|
uint32_t homeBucket = uint32_t(key) & (Size - 1);
|
||||||
Entry entry{ key, wdl, dtz };
|
Entry entry{ key, wdl, dtz };
|
||||||
|
|
||||||
// Ensure last element is empty to avoid overflow when looking up
|
// Ensure last element is empty to avoid overflow when looking up
|
||||||
|
@ -442,7 +442,7 @@ class TBTables {
|
||||||
|
|
||||||
// Robin Hood hashing: If we've probed for longer than this element,
|
// Robin Hood hashing: If we've probed for longer than this element,
|
||||||
// insert here and search for a new spot for the other element instead.
|
// insert here and search for a new spot for the other element instead.
|
||||||
uint32_t otherHomeBucket = (uint32_t)otherKey & (Size - 1);
|
uint32_t otherHomeBucket = uint32_t(otherKey) & (Size - 1);
|
||||||
if (otherHomeBucket > homeBucket) {
|
if (otherHomeBucket > homeBucket) {
|
||||||
std::swap(entry, hashTable[bucket]);
|
std::swap(entry, hashTable[bucket]);
|
||||||
key = otherKey;
|
key = otherKey;
|
||||||
|
@ -456,7 +456,7 @@ class TBTables {
|
||||||
public:
|
public:
|
||||||
template<TBType Type>
|
template<TBType Type>
|
||||||
TBTable<Type>* get(Key key) {
|
TBTable<Type>* get(Key key) {
|
||||||
for (const Entry* entry = &hashTable[(uint32_t)key & (Size - 1)]; ; ++entry) {
|
for (const Entry* entry = &hashTable[uint32_t(key) & (Size - 1)]; ; ++entry) {
|
||||||
if (entry->key == key || !entry->get<Type>())
|
if (entry->key == key || !entry->get<Type>())
|
||||||
return entry->get<Type>();
|
return entry->get<Type>();
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ void TBTables::add(const std::vector<PieceType>& pieces) {
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
MaxCardinality = std::max((int)pieces.size(), MaxCardinality);
|
MaxCardinality = std::max(int(pieces.size()), MaxCardinality);
|
||||||
|
|
||||||
wdlTable.emplace_back(code);
|
wdlTable.emplace_back(code);
|
||||||
dtzTable.emplace_back(wdlTable.back());
|
dtzTable.emplace_back(wdlTable.back());
|
||||||
|
@ -560,7 +560,7 @@ int decompress_pairs(PairsData* d, uint64_t idx) {
|
||||||
offset -= d->blockLength[block++] + 1;
|
offset -= d->blockLength[block++] + 1;
|
||||||
|
|
||||||
// Finally, we find the start address of our block of canonical Huffman symbols
|
// Finally, we find the start address of our block of canonical Huffman symbols
|
||||||
uint32_t* ptr = (uint32_t*)(d->data + ((uint64_t)block * d->sizeofBlock));
|
uint32_t* ptr = (uint32_t*)(d->data + (uint64_t(block) * d->sizeofBlock));
|
||||||
|
|
||||||
// Read the first 64 bits in our block, this is a (truncated) sequence of
|
// Read the first 64 bits in our block, this is a (truncated) sequence of
|
||||||
// unknown number of symbols of unknown length but we know the first one
|
// unknown number of symbols of unknown length but we know the first one
|
||||||
|
@ -600,7 +600,7 @@ int decompress_pairs(PairsData* d, uint64_t idx) {
|
||||||
|
|
||||||
if (buf64Size <= 32) { // Refill the buffer
|
if (buf64Size <= 32) { // Refill the buffer
|
||||||
buf64Size += 32;
|
buf64Size += 32;
|
||||||
buf64 |= (uint64_t)number<uint32_t, BigEndian>(ptr++) << (64 - buf64Size);
|
buf64 |= uint64_t(number<uint32_t, BigEndian>(ptr++)) << (64 - buf64Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,22 +1054,22 @@ uint8_t* set_dtz_map(TBTable<DTZ>& e, uint8_t* data, File maxFile) {
|
||||||
auto flags = e.get(0, f)->flags;
|
auto flags = e.get(0, f)->flags;
|
||||||
if (flags & TBFlag::Mapped) {
|
if (flags & TBFlag::Mapped) {
|
||||||
if (flags & TBFlag::Wide) {
|
if (flags & TBFlag::Wide) {
|
||||||
data += (uintptr_t)data & 1; // Word alignment, we may have a mixed table
|
data += uintptr_t(data) & 1; // Word alignment, we may have a mixed table
|
||||||
for (int i = 0; i < 4; ++i) { // Sequence like 3,x,x,x,1,x,0,2,x,x
|
for (int i = 0; i < 4; ++i) { // Sequence like 3,x,x,x,1,x,0,2,x,x
|
||||||
e.get(0, f)->map_idx[i] = (uint16_t)((uint16_t *)data - (uint16_t *)e.map + 1);
|
e.get(0, f)->map_idx[i] = uint16_t((uint16_t*)data - (uint16_t*)e.map + 1);
|
||||||
data += 2 * number<uint16_t, LittleEndian>(data) + 2;
|
data += 2 * number<uint16_t, LittleEndian>(data) + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
e.get(0, f)->map_idx[i] = (uint16_t)(data - e.map + 1);
|
e.get(0, f)->map_idx[i] = uint16_t(data - e.map + 1);
|
||||||
data += *data + 1;
|
data += *data + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data += (uintptr_t)data & 1; // Word alignment
|
return data += uintptr_t(data) & 1; // Word alignment
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate entry's PairsData records with data from the just memory mapped file.
|
// Populate entry's PairsData records with data from the just memory mapped file.
|
||||||
|
@ -1110,7 +1110,7 @@ void set(T& e, uint8_t* data) {
|
||||||
set_groups(e, e.get(i, f), order[i], f);
|
set_groups(e, e.get(i, f), order[i], f);
|
||||||
}
|
}
|
||||||
|
|
||||||
data += (uintptr_t)data & 1; // Word alignment
|
data += uintptr_t(data) & 1; // Word alignment
|
||||||
|
|
||||||
for (File f = FILE_A; f <= maxFile; ++f)
|
for (File f = FILE_A; f <= maxFile; ++f)
|
||||||
for (int i = 0; i < sides; i++)
|
for (int i = 0; i < sides; i++)
|
||||||
|
@ -1132,7 +1132,7 @@ void set(T& e, uint8_t* data) {
|
||||||
|
|
||||||
for (File f = FILE_A; f <= maxFile; ++f)
|
for (File f = FILE_A; f <= maxFile; ++f)
|
||||||
for (int i = 0; i < sides; i++) {
|
for (int i = 0; i < sides; i++) {
|
||||||
data = (uint8_t*)(((uintptr_t)data + 0x3F) & ~0x3F); // 64 byte alignment
|
data = (uint8_t*)((uintptr_t(data) + 0x3F) & ~0x3F); // 64 byte alignment
|
||||||
(d = e.get(i, f))->data = data;
|
(d = e.get(i, f))->data = data;
|
||||||
data += d->blocksNum * d->sizeofBlock;
|
data += d->blocksNum * d->sizeofBlock;
|
||||||
}
|
}
|
||||||
|
|
20
src/tt.cpp
20
src/tt.cpp
|
@ -39,22 +39,22 @@ TranspositionTable TT; // Our global transposition table
|
||||||
void TTEntry::save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev) {
|
void TTEntry::save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev) {
|
||||||
|
|
||||||
// Preserve any existing move for the same position
|
// Preserve any existing move for the same position
|
||||||
if (m || (uint16_t)k != key16)
|
if (m || uint16_t(k) != key16)
|
||||||
move16 = (uint16_t)m;
|
move16 = uint16_t(m);
|
||||||
|
|
||||||
// Overwrite less valuable entries (cheapest checks first)
|
// Overwrite less valuable entries (cheapest checks first)
|
||||||
if ( b == BOUND_EXACT
|
if ( b == BOUND_EXACT
|
||||||
|| (uint16_t)k != key16
|
|| uint16_t(k) != key16
|
||||||
|| d - DEPTH_OFFSET + 2 * pv > depth8 - 4)
|
|| d - DEPTH_OFFSET + 2 * pv > depth8 - 4)
|
||||||
{
|
{
|
||||||
assert(d > DEPTH_OFFSET);
|
assert(d > DEPTH_OFFSET);
|
||||||
assert(d < 256 + DEPTH_OFFSET);
|
assert(d < 256 + DEPTH_OFFSET);
|
||||||
|
|
||||||
key16 = (uint16_t)k;
|
key16 = uint16_t(k);
|
||||||
depth8 = (uint8_t)(d - DEPTH_OFFSET);
|
depth8 = uint8_t(d - DEPTH_OFFSET);
|
||||||
genBound8 = (uint8_t)(TT.generation8 | uint8_t(pv) << 2 | b);
|
genBound8 = uint8_t(TT.generation8 | uint8_t(pv) << 2 | b);
|
||||||
value16 = (int16_t)v;
|
value16 = int16_t(v);
|
||||||
eval16 = (int16_t)ev;
|
eval16 = int16_t(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,14 +123,14 @@ void TranspositionTable::clear() {
|
||||||
TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
||||||
|
|
||||||
TTEntry* const tte = first_entry(key);
|
TTEntry* const tte = first_entry(key);
|
||||||
const uint16_t key16 = (uint16_t)key; // Use the low 16 bits as key inside the cluster
|
const uint16_t key16 = uint16_t(key); // Use the low 16 bits as key inside the cluster
|
||||||
|
|
||||||
for (int i = 0; i < ClusterSize; ++i)
|
for (int i = 0; i < ClusterSize; ++i)
|
||||||
if (tte[i].key16 == key16 || !tte[i].depth8)
|
if (tte[i].key16 == key16 || !tte[i].depth8)
|
||||||
{
|
{
|
||||||
tte[i].genBound8 = uint8_t(generation8 | (tte[i].genBound8 & (GENERATION_DELTA - 1))); // Refresh
|
tte[i].genBound8 = uint8_t(generation8 | (tte[i].genBound8 & (GENERATION_DELTA - 1))); // Refresh
|
||||||
|
|
||||||
return found = (bool)tte[i].depth8, &tte[i];
|
return found = bool(tte[i].depth8), &tte[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find an entry to be replaced according to the replacement strategy
|
// Find an entry to be replaced according to the replacement strategy
|
||||||
|
|
12
src/tt.h
12
src/tt.h
|
@ -40,12 +40,12 @@ namespace Stockfish {
|
||||||
|
|
||||||
struct TTEntry {
|
struct TTEntry {
|
||||||
|
|
||||||
Move move() const { return (Move )move16; }
|
Move move() const { return Move (move16); }
|
||||||
Value value() const { return (Value)value16; }
|
Value value() const { return Value(value16); }
|
||||||
Value eval() const { return (Value)eval16; }
|
Value eval() const { return Value(eval16); }
|
||||||
Depth depth() const { return (Depth)depth8 + DEPTH_OFFSET; }
|
Depth depth() const { return Depth(depth8 + DEPTH_OFFSET); }
|
||||||
bool is_pv() const { return (bool)(genBound8 & 0x4); }
|
bool is_pv() const { return bool (genBound8 & 0x4); }
|
||||||
Bound bound() const { return (Bound)(genBound8 & 0x3); }
|
Bound bound() const { return Bound(genBound8 & 0x3); }
|
||||||
void save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev);
|
void save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue