Belofte
version 2.2.0
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
* @static Class static function
12
* converge score towards zero in order to force immediate best move
13
* first
14
*/
15
bScore
bSearchScore::convergeScore
(
bScore
const
score)
16
{
17
if
(score > 0) {
18
if
((score >
SCORE_ALMOST_NORMAL
) || (score <
SCORE_ALMOST_DRAW
))
return
score;
19
return
score -
SCORE_CONVERGE_BYDEPTH
;
20
}
21
if
((score < -
SCORE_ALMOST_NORMAL
) || (score > -
SCORE_ALMOST_DRAW
))
return
score;
22
return
score +
SCORE_CONVERGE_BYDEPTH
;
23
}
24
25
bSearchScore
bSearchScore::operator-
()
const
26
{
27
if
(!
m_type
) {
28
if
(
m_score
>
SCORE_ALMOST_NORMAL
||
m_score
< -
SCORE_ALMOST_NORMAL
)
return
*
this
;
29
return
bSearchScore
(-
m_score
);
30
}
else
if
(
m_type
==
tScoreType::SC_ALPHA
) {
31
return
bSearchScore
(-
m_score
,
tScoreType::SC_BETA
);
32
}
else
if
(
m_type
==
tScoreType::SC_BETA
) {
33
return
bSearchScore
(-
m_score
,
tScoreType::SC_ALPHA
);
34
}
35
return
bSearchScore
(-
m_score
,
m_type
);
36
}
37
38
bSearchScore::operator std::string()
const
39
{
40
if
(!
m_type
) {
41
return
engineInterface::scoreAsString
(
m_score
);
42
}
else
if
(
m_type
==
tScoreType::SC_ALPHA
) {
43
return
ALPHA
": "
+
engineInterface::scoreAsString
(
m_score
);
44
}
else
if
(
m_type
==
tScoreType::SC_BETA
) {
45
return
BETA
": "
+
engineInterface::scoreAsString
(
m_score
);
46
}
47
return
engineInterface::scoreAsString
(
m_score
);
48
}
49
50
//-----------------------------------------------------------------------
51
52
// eof
belofte.h
This is the main include file, needs to be included before any other include.
bSearchScore::operator-
bSearchScore operator-() const
Definition
searchscore.cpp:25
bSearchScore::bSearchScore
bSearchScore(bSearchScore &sc)
Definition
searchscore.h:25
bSearchScore::m_score
bScore m_score
Definition
searchscore.h:133
bSearchScore::convergeScore
bScore convergeScore()
Definition
searchscore.h:103
bSearchScore::m_type
scoretype_t m_type
Definition
searchscore.h:134
engineInterface::scoreAsString
static std::string scoreAsString(bScore const score)
Definition
engineinterface.cpp:168
SCORE_ALMOST_NORMAL
constexpr bScore SCORE_ALMOST_NORMAL
Definition
eval.h:22
bScore
int16_t bScore
Definition
eval.h:11
SCORE_ALMOST_DRAW
constexpr bScore SCORE_ALMOST_DRAW
Definition
eval.h:24
SCORE_CONVERGE_BYDEPTH
constexpr bScore SCORE_CONVERGE_BYDEPTH
Definition
eval.h:27
BETA
#define BETA
Definition
search.h:73
ALPHA
#define ALPHA
Definition
search.h:72
SC_BETA
@ SC_BETA
Definition
searchscore.h:15
SC_ALPHA
@ SC_ALPHA
Definition
searchscore.h:15
src
searchscore.cpp
Generated on 06/01/2026 by
1.13.2