]> git.sesse.net Git - stockfish/blob - src/syzygy/tbprobe.h
Update copyright years
[stockfish] / src / syzygy / tbprobe.h
1 /*
2   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3   Copyright (C) 2004-2021 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 <ostream>
23
24 #include "../search.h"
25
26 namespace Tablebases {
27
28 enum WDLScore {
29     WDLLoss        = -2, // Loss
30     WDLBlessedLoss = -1, // Loss, but draw under 50-move rule
31     WDLDraw        =  0, // Draw
32     WDLCursedWin   =  1, // Win, but draw under 50-move rule
33     WDLWin         =  2, // Win
34
35     WDLScoreNone  = -1000
36 };
37
38 // Possible states after a probing operation
39 enum ProbeState {
40     FAIL              =  0, // Probe failed (missing file table)
41     OK                =  1, // Probe succesful
42     CHANGE_STM        = -1, // DTZ should check the other side
43     ZEROING_BEST_MOVE =  2  // Best move zeroes DTZ (capture or pawn move)
44 };
45
46 extern int MaxCardinality;
47
48 void init(const std::string& paths);
49 WDLScore probe_wdl(Position& pos, ProbeState* result);
50 int probe_dtz(Position& pos, ProbeState* result);
51 bool root_probe(Position& pos, Search::RootMoves& rootMoves);
52 bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves);
53 void rank_root_moves(Position& pos, Search::RootMoves& rootMoves);
54
55 inline std::ostream& operator<<(std::ostream& os, const WDLScore v) {
56
57     os << (v == WDLLoss        ? "Loss" :
58            v == WDLBlessedLoss ? "Blessed loss" :
59            v == WDLDraw        ? "Draw" :
60            v == WDLCursedWin   ? "Cursed win" :
61            v == WDLWin         ? "Win" : "None");
62
63     return os;
64 }
65
66 inline std::ostream& operator<<(std::ostream& os, const ProbeState v) {
67
68     os << (v == FAIL              ? "Failed" :
69            v == OK                ? "Success" :
70            v == CHANGE_STM        ? "Probed opponent side" :
71            v == ZEROING_BEST_MOVE ? "Best move zeroes DTZ" : "None");
72
73     return os;
74 }
75
76 }
77
78 #endif