1/*
2 Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3 Copyright (c) 2013 Ronald de Man
4 Copyright (C) 2016-2019 Marco Costalba, Lucas Braesch
5
6 Stockfish is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Stockfish is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef TBPROBE_H
21#define TBPROBE_H
22
23#include <ostream>
24
25#include "../search.h"
26
27namespace Tablebases {
28
29enum WDLScore {
30 WDLLoss = -2, // Loss
31 WDLBlessedLoss = -1, // Loss, but draw under 50-move rule
32 WDLDraw = 0, // Draw
33 WDLCursedWin = 1, // Win, but draw under 50-move rule
34 WDLWin = 2, // Win
35
36 WDLScoreNone = -1000
37};
38
39// Possible states after a probing operation
40enum ProbeState {
41 FAIL = 0, // Probe failed (missing file table)
42 OK = 1, // Probe succesful
43 CHANGE_STM = -1, // DTZ should check the other side
44 ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)
45};
46
47extern int MaxCardinality;
48
49void init(const std::string& paths);
50WDLScore probe_wdl(Position& pos, ProbeState* result);
51int probe_dtz(Position& pos, ProbeState* result);
52bool root_probe(Position& pos, Search::RootMoves& rootMoves);
53bool root_probe_wdl(Position& pos, Search::RootMoves& rootMoves);
54void rank_root_moves(Position& pos, Search::RootMoves& rootMoves);
55
56inline std::ostream& operator<<(std::ostream& os, const WDLScore v) {
57
58 os << (v == WDLLoss ? "Loss" :
59 v == WDLBlessedLoss ? "Blessed loss" :
60 v == WDLDraw ? "Draw" :
61 v == WDLCursedWin ? "Cursed win" :
62 v == WDLWin ? "Win" : "None");
63
64 return os;
65}
66
67inline std::ostream& operator<<(std::ostream& os, const ProbeState v) {
68
69 os << (v == FAIL ? "Failed" :
70 v == OK ? "Success" :
71 v == CHANGE_STM ? "Probed opponent side" :
72 v == ZEROING_BEST_MOVE ? "Best move zeroes DTZ" : "None");
73
74 return os;
75}
76
77}
78
79#endif
80