Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/Stockfish
Path: blob/master/src/score.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 SCORE_H_INCLUDED
20
#define SCORE_H_INCLUDED
21
22
#include <variant>
23
#include <utility>
24
25
#include "types.h"
26
27
namespace Stockfish {
28
29
class Position;
30
31
class Score {
32
public:
33
struct Mate {
34
int plies;
35
};
36
37
struct Tablebase {
38
int plies;
39
bool win;
40
};
41
42
struct InternalUnits {
43
int value;
44
};
45
46
Score() = default;
47
Score(Value v, const Position& pos);
48
49
template<typename T>
50
bool is() const {
51
return std::holds_alternative<T>(score);
52
}
53
54
template<typename T>
55
T get() const {
56
return std::get<T>(score);
57
}
58
59
template<typename F>
60
decltype(auto) visit(F&& f) const {
61
return std::visit(std::forward<F>(f), score);
62
}
63
64
private:
65
std::variant<Mate, Tablebase, InternalUnits> score;
66
};
67
68
}
69
70
#endif // #ifndef SCORE_H_INCLUDED
71
72