Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/Stockfish
Path: blob/master/src/syzygy/tbprobe.h
376 views
1
/*
2
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3
Copyright (C) 2004-2025 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 <string>
23
#include <vector>
24
25
26
namespace Stockfish {
27
class Position;
28
class OptionsMap;
29
30
using Depth = int;
31
32
namespace Search {
33
struct RootMove;
34
using RootMoves = std::vector<RootMove>;
35
}
36
}
37
38
namespace Stockfish::Tablebases {
39
40
struct Config {
41
int cardinality = 0;
42
bool rootInTB = false;
43
bool useRule50 = false;
44
Depth probeDepth = 0;
45
};
46
47
enum WDLScore {
48
WDLLoss = -2, // Loss
49
WDLBlessedLoss = -1, // Loss, but draw under 50-move rule
50
WDLDraw = 0, // Draw
51
WDLCursedWin = 1, // Win, but draw under 50-move rule
52
WDLWin = 2, // Win
53
};
54
55
// Possible states after a probing operation
56
enum ProbeState {
57
FAIL = 0, // Probe failed (missing file table)
58
OK = 1, // Probe successful
59
CHANGE_STM = -1, // DTZ should check the other side
60
ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)
61
};
62
63
extern int MaxCardinality;
64
65
66
void init(const std::string& paths);
67
WDLScore probe_wdl(Position& pos, ProbeState* result);
68
int probe_dtz(Position& pos, ProbeState* result);
69
bool root_probe(Position& pos, Search::RootMoves& rootMoves, bool rule50, bool rankDTZ);
70
bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, bool rule50);
71
Config rank_root_moves(const OptionsMap& options,
72
Position& pos,
73
Search::RootMoves& rootMoves,
74
bool rankDTZ = false);
75
76
} // namespace Stockfish::Tablebases
77
78
#endif
79
80