Belofte version 2.1.8
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 final : public bConfigurableGame {
21public:
22 bGame();
23 ~bGame() override;
24
25 bGame(bGame const&) = delete;
26 bGame(bGame&&) = delete;
27 bGame& operator=(bGame const&) = delete;
28 bGame& operator=(bGame&&) = delete;
29
30 operator std::string() const;
31
32 void newGame();
33 void setFEN(std::string const& fenstr);
34 void setFENInitialPos();
35
36 bool playGameMove(bCoordMove const& coordmove);
37 bool playGameMoveSeries(std::string const& coordmoves);
38 void revertGameMove();
39
40 std::string getResult(gameResult_t rs) const;
41 void setResult(gameResult_t rs);
42 gameResult_t getResult() const { return m_result; }
43 void setExpecting(std::string const& s);
44 bool isExpecting(std::string const& s) const;
45 std::string const& getExpecting() const;
46
47 bEpdResult evalEpdPosition(bFen const& fen, bEpdOpCodes& opcodes);
48 bEpdResult evalPerftResult(bFen const& fen, bEpdOpCodes& opcodes);
49
51
52 void setLevel(bLevel const& l) { m_level = l; }
53 bLevel& getLevel() { return m_level; }
54 positions_t& getPositions() { return m_positions; }
55 void setPlayerName(std::string const& n);
56
57 void DoSearch();
58 void AbortSearch();
59 void WaitForSearchEnd();
60 int64_t DoPerft(bSearchAlgorithm& sa, int const d);
61
62 bScore EvalForPlayer(bBoard const& b);
64
65private:
66 std::string movesinpgnformat() const;
67
68 bEpdResult evalEpdResult(bEpdOpCodes& opcodes, bPgnMove const& m);
69
70 gameResult_t m_result = gameResult::GR_UNKNOWN; // TODO: move to last position
71 gameAttributes_t m_pgnTags;
72 gameAttributes_t m_optTags;
73 positions_t m_positions; // TODO: convert to class bPositions
74 bLevel m_level;
75 std::string m_expecting; // next command should return according to expectation
76};
77
78#endif // defined GAME_H
79
80// eof
int16_t bScore
board
Definition board.h:147
allow custom methods to be attached to game
simple coordmove, with 4 characters, or 5 characters in case of promotion mostly used for interface
Definition coordmove.h:14
FEN string.
Definition fen.h:14
game representation, singleton
Definition game.h:20
std::string const & getExpecting() const
Definition game.cpp:178
bScore EvalForPlayer(bBoard const &b)
Definition game.cpp:151
bool playGameMove(bCoordMove const &coordmove)
Definition game.cpp:208
void revertGameMove()
required for Winboard protocol, not supported in UCI (except debug)
Definition game.cpp:237
void setPlayerName(std::string const &n)
Definition game.cpp:62
bEpdResult evalPerftResult(bFen const &fen, bEpdOpCodes &opcodes)
check perft result for different depths D[1-99] # perft test - nodes
Definition game.cpp:304
bGame(bGame &&)=delete
void WaitForSearchEnd()
Called in separate thread, sure to terminate normally.
Definition game.cpp:108
void setExpecting(std::string const &s)
Following command should return value as expected.
Definition game.cpp:164
bGame & operator=(bGame const &)=delete
void AbortSearch()
Definition game.cpp:100
positions_t & getPositions()
Definition game.h:54
void newGame()
Definition game.cpp:28
bLevel & getLevel()
Definition game.h:53
void DoSearch()
Start search thread and exit in case of batch mode, will wait until end of search.
Definition game.cpp:81
gameResult_t EvalFinalScore(bBoard const &b)
Definition game.cpp:156
bGame()
Definition game.cpp:15
bool playGameMoveSeries(std::string const &coordmoves)
all moves in a single string
Definition game.cpp:200
void setResult(gameResult_t rs)
Definition game.cpp:191
bGame & operator=(bGame &&)=delete
void setFEN(std::string const &fenstr)
Definition game.cpp:54
gameResult_t getResult() const
Definition game.h:42
bGame(bGame const &)=delete
bEpdResult evalEpdPosition(bFen const &fen, bEpdOpCodes &opcodes)
do actual epd position test
Definition game.cpp:246
~bGame() override
Definition game.cpp:24
int64_t DoPerft(bSearchAlgorithm &sa, int const d)
do perft search at depth
Definition game.cpp:126
bBoard & getCurrentPosition()
Definition game.cpp:73
bool isExpecting(std::string const &s) const
Definition game.cpp:170
void setLevel(bLevel const &l)
Definition game.h:52
void setFENInitialPos()
Definition game.cpp:46
Definition level.h:49
PgnMove is for user-interface only.
Definition pgnmove.h:12
int bEpdResult
std::map< std::string, std::string > bEpdOpCodes
@ GR_UNKNOWN
Definition eval.h:34
enum gameResult gameResult_t
Definition eval.h:41
std::vector< bBoard > positions_t
Definition game.h:15
std::map< std::string, std::string > gameAttributes_t
Definition game.h:14