/*1Stockfish, a UCI chess playing engine derived from Glaurung 2.12Copyright (C) 2004-2025 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 <string>22#include <vector>232425namespace Stockfish {26class Position;27class OptionsMap;2829using Depth = int;3031namespace Search {32struct RootMove;33using RootMoves = std::vector<RootMove>;34}35}3637namespace Stockfish::Tablebases {3839struct Config {40int cardinality = 0;41bool rootInTB = false;42bool useRule50 = false;43Depth probeDepth = 0;44};4546enum WDLScore {47WDLLoss = -2, // Loss48WDLBlessedLoss = -1, // Loss, but draw under 50-move rule49WDLDraw = 0, // Draw50WDLCursedWin = 1, // Win, but draw under 50-move rule51WDLWin = 2, // Win52};5354// Possible states after a probing operation55enum ProbeState {56FAIL = 0, // Probe failed (missing file table)57OK = 1, // Probe successful58CHANGE_STM = -1, // DTZ should check the other side59ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)60};6162extern int MaxCardinality;636465void init(const std::string& paths);66WDLScore probe_wdl(Position& pos, ProbeState* result);67int probe_dtz(Position& pos, ProbeState* result);68bool root_probe(Position& pos, Search::RootMoves& rootMoves, bool rule50, bool rankDTZ);69bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, bool rule50);70Config rank_root_moves(const OptionsMap& options,71Position& pos,72Search::RootMoves& rootMoves,73bool rankDTZ = false);7475} // namespace Stockfish::Tablebases7677#endif787980