/*1Stockfish, a UCI chess playing engine derived from Glaurung 2.12Copyright (C) 2004-2026 The Stockfish developers (see AUTHORS file)34Stockfish is free software: you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.89Stockfish is distributed in the hope that it will be useful,10but WITHOUT ANY WARRANTY; without even the implied warranty of11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12GNU General Public License for more details.1314You should have received a copy of the GNU General Public License15along with this program. If not, see <http://www.gnu.org/licenses/>.16*/1718#ifndef TBPROBE_H19#define TBPROBE_H2021#include <functional>22#include <string>23#include <vector>242526namespace Stockfish {27class Position;28class OptionsMap;2930using Depth = int;3132namespace Search {33struct RootMove;34using RootMoves = std::vector<RootMove>;35}36}3738namespace Stockfish::Tablebases {3940struct Config {41int cardinality = 0;42bool rootInTB = false;43bool useRule50 = false;44Depth probeDepth = 0;45};4647enum WDLScore {48WDLLoss = -2, // Loss49WDLBlessedLoss = -1, // Loss, but draw under 50-move rule50WDLDraw = 0, // Draw51WDLCursedWin = 1, // Win, but draw under 50-move rule52WDLWin = 2, // Win53};5455// Possible states after a probing operation56enum ProbeState {57FAIL = 0, // Probe failed (missing file table)58OK = 1, // Probe successful59CHANGE_STM = -1, // DTZ should check the other side60ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)61};6263extern int MaxCardinality;646566void init(const std::string& paths);67WDLScore probe_wdl(Position& pos, ProbeState* result);68int probe_dtz(Position& pos, ProbeState* result);69bool root_probe(Position& pos,70Search::RootMoves& rootMoves,71bool rule50,72bool rankDTZ,73const std::function<bool()>& time_abort);74bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, bool rule50);75Config rank_root_moves(76const OptionsMap& options,77Position& pos,78Search::RootMoves& rootMoves,79bool rankDTZ = false,80const std::function<bool()>& time_abort = []() { return false; });8182} // namespace Stockfish::Tablebases8384#endif858687