Belofte version 2.1.9
A promising chess program using the UCI or Winboard interface
game.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: game.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(GAME_H)
9#define GAME_H
10
11//-----------------------------------------------------------------------
12// helpers for bGame class
13
14typedef std::map<std::string, std::string> gameAttributes_t;
15typedef std::vector<bBoard> positions_t;
16
17//-----------------------------------------------------------------------
18
19/** game representation, singleton */
20class bGame : public bConfigurableGame {
21public:
22 bGame();
23 ~bGame() override
24 {}
25
26 bGame(bGame const&) = delete;
27 bGame(bGame&&) = delete;
28 bGame& operator=(bGame const&) = delete;
29 bGame& operator=(bGame&&) = delete;
30
31 void newGame();
32 void setFEN(std::string const& fenstr);
33 void setFENInitialPos();
34
35 bool playGameMove(bCoordMove const& coordmove);
36 bool playGameMoveSeries(std::string const& coordmoves);
37 void revertGameMove(std::string const& reason);
38
39 std::string getResult(gameResult_t gr) const;
40 void setResult(gameResult_t gr);
42 { return m_result; }
43
44 bool isExpecting(std::string const& s) const
45 { /// @todo improve by redirecting App().bout
46 return (m_expecting == "" || m_expecting == s); }
47 void setExpecting(std::string const& s)
48 { m_expecting = s; }
49 std::string const& getExpecting() const
50 { return m_expecting; }
51
52 /// @todo check why copy constructor is called, check if we should return
53 /// anything else but positions.back()
55 { return m_positions.back(); }
56
57 void setLevel(bLevel const& l)
58 { m_level = l; }
60 { return m_level; }
62 { return m_positions; }
63 void setPlayerName(std::string const& n);
64
65 void DoSearch();
66 void AbortSearch();
67 void WaitForSearchEnd();
68
69 bScore EvalForPlayer(bBoard const& b);
70
71 // test related elements
72 int64_t DoPerftCommand(depth_t const d);
73 int64_t DoPerft(bSearchAlgorithm& sa, depth_t const d);
75
76 operator std::string() const;
77
78private:
79 std::string movesinpgnformat() const;
80
81 gameResult_t m_result = gameResult::GR_UNKNOWN; /// @todo move to last position
82 gameAttributes_t m_pgnTags;
83 gameAttributes_t m_optTags;
84 positions_t m_positions; /// @todo convert to class bPositions
85 bLevel m_level;
86 std::string m_expecting; // next command should return according to expectation
87};
88
89#endif // defined GAME_H
90
91// eof
int_fast8_t depth_t
Definition belofte.h:103
board
Definition board.h:45
simple coordmove, with 4 characters, or 5 characters in case of promotion mostly used for interface
Definition coordmove.h:15
FEN string.
Definition fen.h:14
std::string const & getExpecting() const
Definition game.h:49
bMove getEpdMoveInPosition(bFen const &fen)
do actual epd position test
Definition game.cpp:251
bScore EvalForPlayer(bBoard const &b)
Definition game.cpp:166
bool playGameMove(bCoordMove const &coordmove)
apply move, it will change the current board by updating the move played it will also add the new boa...
Definition game.cpp:201
void setResult(gameResult_t gr)
Definition game.cpp:179
void setPlayerName(std::string const &n)
Definition game.cpp:58
int64_t DoPerft(bSearchAlgorithm &sa, depth_t const d)
do perft search at depth in case of Perft algorithm, temporarily set evaltype to None
Definition game.cpp:131
bGame(bGame &&)=delete
void WaitForSearchEnd()
Called in separate thread, sure to terminate normally.
Definition game.cpp:98
void setExpecting(std::string const &s)
Definition game.h:47
bGame & operator=(bGame const &)=delete
void AbortSearch()
Definition game.cpp:90
positions_t & getPositions()
Definition game.h:61
void newGame()
Definition game.cpp:24
void revertGameMove(std::string const &reason)
required for Winboard protocol, not supported in UCI (except debug)
Definition game.cpp:237
bLevel & getLevel()
Definition game.h:59
void DoSearch()
Start search thread and exit in case of batch mode, will wait until end of search.
Definition game.cpp:71
bGame()
Definition game.cpp:15
bool playGameMoveSeries(std::string const &coordmoves)
all moves in a single string
Definition game.cpp:189
bGame & operator=(bGame &&)=delete
void setFEN(std::string const &fenstr)
Definition game.cpp:50
int64_t DoPerftCommand(depth_t const d)
do perft search using SearchPerft algorithm at depth
Definition game.cpp:121
gameResult_t getResult() const
Definition game.h:41
bGame(bGame const &)=delete
~bGame() override
Definition game.h:23
bBoard & getCurrentPosition()
Definition game.h:54
bool isExpecting(std::string const &s) const
Definition game.h:44
void setLevel(bLevel const &l)
Definition game.h:57
void setFENInitialPos()
Definition game.cpp:42
Definition level.h:48
Definition move.h:13
@ GR_UNKNOWN
Definition eval.h:36
enum gameResult gameResult_t
Definition eval.h:43
int16_t bScore
Definition eval.h:11
std::vector< bBoard > positions_t
Definition game.h:15
std::map< std::string, std::string > gameAttributes_t
Definition game.h:14