Belofte version 2.1.9
A promising chess program using the UCI or Winboard interface
searchscore.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: searchscore.h
3 * Project: part of belofte - A Promising Chess Program
4 * Author: yves
5 * SPDX-License-Identifier: GPL-2.0-only
6+----------------------------------------------------------------------*/
7
8#if !defined(SEARCHSCORE_H)
9#define SEARCHSCORE_H
10
11//-----------------------------------------------------------------------
12
18
20
21//-----------------------------------------------------------------------
22
24public:
32 : u_scoreInfo{std::move(sc.u_scoreInfo)}
33 {}
34 explicit bSearchScore(bScore const& score)
35 : m_score{score}
36 {}
37 explicit bSearchScore(bScore const& score, scoretype_t const& st)
38 : m_score{score}
39 , m_type{st}
40 {}
43
45 { m_score = score;
46 return *this;
47 }
48
49 bSearchScore operator-() const;
50
51 bool operator>(bScore const& rhsc)
52 { return realScore() > rhsc; }
53 bool operator>(bSearchScore const& rhsc)
54 { return realScore() > rhsc.realScore(); }
55 bool operator>=(bSearchScore const& rhsc)
56 { return realScore() >= rhsc.realScore(); }
57 bool operator<(bScore const& rhsc)
58 { return realScore() < rhsc; }
59 bool operator<(bSearchScore const& rhsc)
60 { return realScore() < rhsc.realScore(); }
61 bool operator<=(bSearchScore const& rhsc)
62 { return realScore() <= rhsc.realScore(); }
63
64 constexpr bScore getScore() const
65 { return m_score; }
66 constexpr bScore realScore() const
69 }
70 constexpr bool isWinning() const
71 { return realScore() > SCORE_WINNING; }
72 inline bool improvesOn(bSearchScore const& sc)
73 { return realScore() > sc.realScore(); }
74 inline bool improvesOn(bScore const &margin, bSearchScore const& sc) const
75 { return (realScore() - margin) >= sc.realScore(); }
76 inline bool improvesOn(bScore const& sc)
77 { return realScore() > bSearchScore::realScore(sc); }
78 inline bool improvesOn(bScore const &margin, bScore const& sc) const
79 { return (realScore() - margin) >= bSearchScore::realScore(sc); }
80
81 std::string const operator+(std::string const& rhs)
82 { return operator std::string() + rhs; }
83 friend std::string const operator+(std::string const& lhs, bSearchScore const& sc)
84 { return lhs + sc.operator std::string(); }
85
86 friend bool operator>(bScore const& lhsc, bSearchScore const& rhsc)
87 { return lhsc > rhsc.realScore(); }
88 friend bool operator>=(bScore const& lhsc, bSearchScore const& rhsc)
89 { return lhsc >= rhsc.realScore(); }
90 friend bool operator<(bScore const& lhsc, bSearchScore const& rhsc)
91 { return lhsc < rhsc.realScore(); }
92 friend bool operator<=(bScore const& lhsc, bSearchScore const& rhsc)
93 { return lhsc <= rhsc.realScore(); }
94
99
100public:
101 // class static
102 static bScore convergeScore(bScore const score);
103
104 constexpr static bScore realScore(bScore const score)
105 { return bSearchScore::isDrawScore(score) ? 0
106 : ((score == SCORE_PUNDEFINED) ? SCORE_UNDEFINED : score);
107 }
108 constexpr static bool isUndefinedScore(bScore const score)
109 { return ((score == SCORE_PUNDEFINED) || (score == SCORE_UNDEFINED)); }
110 constexpr static bool isDrawScore(bScore const score)
111 { return (score == SCORE_THEORETIC_DRAW) || (score == SCORE_PRACTICAL_DRAW); }
112
113 operator std::string() const;
114
115private:
116 union {
117 uint32_t u_scoreInfo;
118 struct {
121 };
122 };
123};
124
125//-----------------------------------------------------------------------
126
127#endif // defined SEARCHSCORE_H
128
129// eof
bSearchScore(bSearchScore const &sc)
Definition searchscore.h:28
bSearchScore operator-() const
constexpr bScore realScore() const
Definition searchscore.h:66
bSearchScore(bSearchScore &sc)
Definition searchscore.h:25
static constexpr bool isDrawScore(bScore const score)
constexpr bScore getScore() const
Definition searchscore.h:64
bool operator>(bSearchScore const &rhsc)
Definition searchscore.h:53
bool improvesOn(bSearchScore const &sc)
Definition searchscore.h:72
friend std::string const operator+(std::string const &lhs, bSearchScore const &sc)
Definition searchscore.h:83
friend bool operator<=(bScore const &lhsc, bSearchScore const &rhsc)
Definition searchscore.h:92
bool improvesOn(bScore const &margin, bScore const &sc) const
Definition searchscore.h:78
bSearchScore(bSearchScore &&sc)
Definition searchscore.h:31
bool improvesOn(bScore const &margin, bSearchScore const &sc) const
Definition searchscore.h:74
bSearchScore(bScore const &score, scoretype_t const &st)
Definition searchscore.h:37
bool improvesOn(bScore const &sc)
Definition searchscore.h:76
bool operator>=(bSearchScore const &rhsc)
Definition searchscore.h:55
bool operator<(bScore const &rhsc)
Definition searchscore.h:57
bool operator>(bScore const &rhsc)
Definition searchscore.h:51
constexpr bool isWinning() const
Definition searchscore.h:70
friend bool operator>(bScore const &lhsc, bSearchScore const &rhsc)
Definition searchscore.h:86
friend bool operator<(bScore const &lhsc, bSearchScore const &rhsc)
Definition searchscore.h:90
static constexpr bScore realScore(bScore const score)
std::string const operator+(std::string const &rhs)
Definition searchscore.h:81
bool operator<=(bSearchScore const &rhsc)
Definition searchscore.h:61
bSearchScore(bScore const &score)
Definition searchscore.h:34
bScore convergeScore()
Definition searchscore.h:95
friend bool operator>=(bScore const &lhsc, bSearchScore const &rhsc)
Definition searchscore.h:88
bool operator<(bSearchScore const &rhsc)
Definition searchscore.h:59
static constexpr bool isUndefinedScore(bScore const score)
uint32_t u_scoreInfo
scoretype_t m_type
bSearchScore & operator=(bScore const &score)
Definition searchscore.h:44
constexpr bScore SCORE_PUNDEFINED
Definition eval.h:20
int16_t bScore
Definition eval.h:11
constexpr bScore SCORE_PRACTICAL_DRAW
Definition eval.h:18
constexpr bScore SCORE_WINNING
Definition eval.h:25
constexpr bScore SCORE_UNDEFINED
Definition eval.h:21
constexpr bScore SCORE_THEORETIC_DRAW
Definition eval.h:17
tScoreType
Definition searchscore.h:13
@ SC_BETA
Definition searchscore.h:15
@ SC_SIZE
Definition searchscore.h:16
@ SC_UNDEF
Definition searchscore.h:14
@ SC_ALPHA
Definition searchscore.h:15
enum tScoreType scoretype_t
Definition searchscore.h:19