Belofte  version 2.1.5
A promising chess program using the UCI or Winboard interface
searchscore.cpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------+
2  * File: searchscore.cpp
3  * Project: part of belofte - A Promising Chess Program
4  * Author: yves
5  * SPDX-License-Identifier: GPL-2.0-only
6 +----------------------------------------------------------------------*/
7 
8 #include "belofte.h"
9 
10 //-----------------------------------------------------------------------
11 
13  : m_score{sc}
14 {
15 }
16 
17 bSearchScore::bSearchScore(bScore const& sc, scoretype_t const& st) noexcept
18  : m_score{sc}
19  , m_type{st}
20 {
21 }
22 
24  : m_score{sc.m_score}
25  , m_type{sc.m_type}
26 {
27 }
28 
30  : m_score{std::move(sc.m_score)}
31  , m_type{std::move(sc.m_type)}
32 {
33 }
34 
35 bSearchScore::bSearchScore(bBestMoveInfo const& bmi, scoretype_t const& st) noexcept
36  : m_score{std::move(bmi.getScore())}
37  , m_type{st}
38 {
39 }
40 
42 {
43  m_score = std::move(sc.m_score);
44  m_type = std::move(sc.m_type);
45 
46  return *this;
47 }
48 
50 {
51  m_score = sc;
52 
53  return *this;
54 }
55 
57 {
58  m_score = sc;
59 
60  return *this;
61 }
62 
64 {
65 }
66 
68 {
69  if (!m_type) {
70  bSearchScore(-m_score);
71  } else if (m_type == tScoreType::SC_ALPHA) {
72  return bSearchScore(-m_score, tScoreType::SC_BETA);
73  } else if (m_type == tScoreType::SC_BETA) {
74  return bSearchScore(-m_score, tScoreType::SC_ALPHA);
75  }
76  return bSearchScore(-m_score, m_type);
77 }
78 
79 std::string const operator+(std::string const& lhs, bSearchScore const& sc)
80 {
81  return lhs + sc.operator std::string();
82 }
83 
84 std::string const operator+(bSearchScore const& sc, std::string const& rhs)
85 {
86  return sc.operator std::string() + rhs;
87 }
88 
89 bool operator>(bScore const& lhsc, bSearchScore const& rhsc)
90 {
91  return lhsc > rhsc.getRealScore();
92 }
93 
94 bool operator>=(bScore const& lhsc, bSearchScore const& rhsc)
95 {
96  return lhsc >= rhsc.getRealScore();
97 }
98 
99 bool operator>(bSearchScore const& lhsc, bScore const& rhsc)
100 {
101  return lhsc.getRealScore() > rhsc;
102 }
103 
104 bool operator>(bSearchScore const& lhsc, bSearchScore const& rhsc)
105 {
106  return lhsc.getRealScore() > rhsc.getRealScore();
107 }
108 
109 bSearchScore::operator std::string() const
110 {
111  if (!m_type) {
112  return belofte::scoreAsStr(m_score);
113 #if defined(BELOFTE_NOUNICODE)
114  } else if (m_type == tScoreType::SC_ALPHA) {
115  return "alpha: " + belofte::scoreAsStr(m_score);
116  } else if (m_type == tScoreType::SC_BETA) {
117  return "beta: " + belofte::scoreAsStr(m_score);
118  } else if (m_type == tScoreType::SC_CHILD) {
119  return "search: " + belofte::scoreAsStr(m_score);
120  } else if (m_type == tScoreType::SC_BEST) {
121  return "best: " + belofte::scoreAsStr(m_score);
122 #else
123  } else if (m_type == tScoreType::SC_ALPHA) {
124  return "𝛼: " + belofte::scoreAsStr(m_score);
125  } else if (m_type == tScoreType::SC_BETA) {
126  return "𝛽: " + belofte::scoreAsStr(m_score);
127  } else if (m_type == tScoreType::SC_CHILD) {
128  return "⅀: " + belofte::scoreAsStr(m_score);
129  } else if (m_type == tScoreType::SC_BEST) {
130  return "↑: " + belofte::scoreAsStr(m_score);
131 #endif
132  }
133  return belofte::scoreAsStr(m_score);
134 }
135 
136 //-----------------------------------------------------------------------
137 
138 // eof
This is the main include file, needs to be included before any other include.
int_fast16_t bScore
used to return id of move in movelist
Definition: belofte.h:104
bSearchScore operator-() const
Definition: searchscore.cpp:67
bSearchScore & operator=(bSearchScore &&sc) noexcept
Definition: searchscore.cpp:41
bScore getRealScore() const
Definition: searchscore.h:39
bSearchScore(bSearchScore const &sc) noexcept
Definition: searchscore.cpp:23
std::string scoreAsStr(bScore const sc)
Definition: util.cpp:250
std::string const operator+(std::string const &lhs, bSearchScore const &sc)
Definition: searchscore.cpp:79
bool operator>(bScore const &lhsc, bSearchScore const &rhsc)
Definition: searchscore.cpp:89
bool operator>=(bScore const &lhsc, bSearchScore const &rhsc)
Definition: searchscore.cpp:94
@ SC_BETA
Definition: searchscore.h:15
@ SC_BEST
Definition: searchscore.h:15
@ SC_CHILD
Definition: searchscore.h:15
@ SC_ALPHA
Definition: searchscore.h:15
enum tScoreType scoretype_t
Definition: searchscore.h:19