Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/stockfish
Path: blob/master/src/syzygy/tbprobe.h
502 views
1
/*
2
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3
Copyright (C) 2004-2026 The Stockfish developers (see AUTHORS file)
4
5
Stockfish is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
Stockfish is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef TBPROBE_H
20
#define TBPROBE_H
21
22
#include <functional>
23
#include <string>
24
#include <vector>
25
26
27
namespace Stockfish {
28
class Position;
29
class OptionsMap;
30
31
using Depth = int;
32
33
namespace Search {
34
struct RootMove;
35
using RootMoves = std::vector<RootMove>;
36
}
37
}
38
39
namespace Stockfish::Tablebases {
40
41
struct Config {
42
int cardinality = 0;
43
bool rootInTB = false;
44
bool useRule50 = false;
45
Depth probeDepth = 0;
46
};
47
48
enum WDLScore {
49
WDLLoss = -2, // Loss
50
WDLBlessedLoss = -1, // Loss, but draw under 50-move rule
51
WDLDraw = 0, // Draw
52
WDLCursedWin = 1, // Win, but draw under 50-move rule
53
WDLWin = 2, // Win
54
};
55
56
// Possible states after a probing operation
57
enum ProbeState {
58
FAIL = 0, // Probe failed (missing file table)
59
OK = 1, // Probe successful
60
CHANGE_STM = -1, // DTZ should check the other side
61
ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)
62
};
63
64
extern int MaxCardinality;
65
66
67
void init(const std::string& paths);
68
WDLScore probe_wdl(Position& pos, ProbeState* result);
69
int probe_dtz(Position& pos, ProbeState* result);
70
bool root_probe(Position& pos,
71
Search::RootMoves& rootMoves,
72
bool rule50,
73
bool rankDTZ,
74
const std::function<bool()>& time_abort);
75
bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, bool rule50);
76
Config rank_root_moves(
77
const OptionsMap& options,
78
Position& pos,
79
Search::RootMoves& rootMoves,
80
bool rankDTZ = false,
81
const std::function<bool()>& time_abort = []() { return false; });
82
83
} // namespace Stockfish::Tablebases
84
85
#endif
86
87