Belofte version 2.1.9
A promising chess program using the UCI or Winboard interface
move.cpp
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: move.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
12class engineInterface;
13
14//-----------------------------------------------------------------------
15
16/// @todo convert to move annotation to be used in PgnMove as well
17std::string bMove::getMoveEvalStr() const
18{
19 std::string str;
20 if (isCheck()) {
21 if (!isDrawScore() && isMateMove()) {
22 str = "#";
23 } else {
24 str = "+";
25 }
26 }
27 if (isEPMove()) str += (str != "") ? " e.p." : "e.p.";
28 else if (isCapture()) str += (str != "") ? " x" : "x";
29 if (!isUndefinedScore()) {
30 if (str != "") str += " ";
31 str += engineInterface::scoreAsString(m_score);
32 }
33 if (str != "") return " {" + str + "}";
34 return "";
35}
36
37/**
38 * Check if end of game flag is set, and not forced draw
39 * @return true if game ended by mate
40 */
42{
43 if (isDrawScore()) return false;
44 if (getGameEnd()) return true;
45 if ((!isUndefinedScore()) && isCheck()) {
46 if (getAbsScore() >= (SCORE_MATE - SCORE_CONVERGE_BYDEPTH)) return true;
47 }
48 return false;
49}
50
51// eof
This is the main include file, needs to be included before any other include.
constexpr bool isCapture() const
Definition basicmove.h:93
constexpr bool isEPMove() const
Definition basicmove.h:126
constexpr bool getGameEnd() const
Definition basicmove.h:115
constexpr bool isCheck() const
Definition basicmove.h:109
constexpr bool isUndefinedScore() const
Definition move.h:61
constexpr bool isDrawScore() const
Definition move.h:59
std::string getMoveEvalStr() const
Definition move.cpp:17
bool isMateMove() const
Check if end of game flag is set, and not forced draw.
Definition move.cpp:41
constexpr bScore getAbsScore() const
Definition move.h:57
implementation of user interface
static std::string scoreAsString(bScore const score)
constexpr bScore SCORE_MATE
Definition eval.h:24
constexpr bScore SCORE_CONVERGE_BYDEPTH
Definition eval.h:30