Update to Stockfish 14

This commit is contained in:
Peter Osterlund
2021-07-02 20:50:36 +02:00
parent fe7a8fac11
commit 4f7930acf0
61 changed files with 2020 additions and 1568 deletions

View File

@@ -50,9 +50,11 @@
#include <windows.h>
#endif
using namespace Tablebases;
using namespace Stockfish::Tablebases;
int Tablebases::MaxCardinality;
int Stockfish::Tablebases::MaxCardinality;
namespace Stockfish {
namespace {
@@ -103,9 +105,6 @@ template<> inline void swap_endian<uint8_t>(uint8_t&) {}
template<typename T, int LE> T number(void* addr)
{
static const union { uint32_t i; char c[4]; } Le = { 0x01020304 };
static const bool IsLittleEndian = (Le.c[0] == 4);
T v;
if ((uintptr_t)addr & (alignof(T) - 1)) // Unaligned pointer (very rare)
@@ -190,7 +189,8 @@ public:
std::stringstream ss(Paths);
std::string path;
while (std::getline(ss, path, SepChar)) {
while (std::getline(ss, path, SepChar))
{
fname = path + "/" + f;
std::ifstream::open(fname);
if (is_open())
@@ -472,8 +472,6 @@ TBTables TBTables;
// If the corresponding file exists two new objects TBTable<WDL> and TBTable<DTZ>
// are created and added to the lists and hash table. Called at init time.
void TBTables::add(const std::vector<PieceType>& pieces) {
if (sizeof(char*) < 8 && pieces.size() >= 6)
return; // Not enough address space to support 6-men TB on 32-bit OS
std::string code;
@@ -567,7 +565,8 @@ int decompress_pairs(PairsData* d, uint64_t idx) {
int buf64Size = 64;
Sym sym;
while (true) {
while (true)
{
int len = 0; // This is the symbol length - d->min_sym_len
// Now get the symbol length. For any symbol s64 of length l right-padded
@@ -605,8 +604,8 @@ int decompress_pairs(PairsData* d, uint64_t idx) {
// We binary-search for our value recursively expanding into the left and
// right child symbols until we reach a leaf node where symlen[sym] + 1 == 1
// that will store the value we need.
while (d->symlen[sym]) {
while (d->symlen[sym])
{
Sym left = d->btree[sym].get<LR::Left>();
// If a symbol contains 36 sub-symbols (d->symlen[sym] + 1 = 36) and
@@ -711,7 +710,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
leadPawns = b = pos.pieces(color_of(pc), PAWN);
do
squares[size++] = pop_lsb(&b) ^ flipSquares;
squares[size++] = pop_lsb(b) ^ flipSquares;
while (b);
leadPawnsCnt = size;
@@ -731,7 +730,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
// directly map them to the correct color and square.
b = pos.pieces() ^ leadPawns;
do {
Square s = pop_lsb(&b);
Square s = pop_lsb(b);
squares[size] = s ^ flipSquares;
pieces[size++] = Piece(pos.piece_on(s) ^ flipColor);
} while (b);
@@ -1537,6 +1536,14 @@ bool Tablebases::root_probe(Position& pos, Search::RootMoves& rootMoves) {
WDLScore wdl = -probe_wdl(pos, &result);
dtz = dtz_before_zeroing(wdl);
}
else if (pos.is_draw(1))
{
// In case a root move leads to a draw by repetition or
// 50-move rule, we set dtz to zero. Note: since we are
// only 1 ply from the root, this must be a true 3-fold
// repetition inside the game history.
dtz = 0;
}
else
{
// Otherwise, take dtz for the new position and correct by 1 ply
@@ -1587,6 +1594,7 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) {
ProbeState result;
StateInfo st;
WDLScore wdl;
bool rule50 = Options["Syzygy50MoveRule"];
@@ -1595,7 +1603,10 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) {
{
pos.do_move(m.pv[0], st);
WDLScore wdl = -probe_wdl(pos, &result);
if (pos.is_draw(1))
wdl = WDLDraw;
else
wdl = -probe_wdl(pos, &result);
pos.undo_move(m.pv[0]);
@@ -1612,3 +1623,5 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves) {
return true;
}
} // namespace Stockfish