Belofte version 2.2.0
A promising chess program using the UCI or Winboard interface
bGame Class Reference

game representation, singleton More...

#include <game.h>

+ Inheritance diagram for bGame:
+ Collaboration diagram for bGame:

Public Member Functions

 bGame ()
 
 ~bGame () override
 
 bGame (bGame const &)=delete
 
 bGame (bGame &&)=delete
 
bGameoperator= (bGame const &)=delete
 
bGameoperator= (bGame &&)=delete
 
void newGame ()
 
void setFEN (std::string const &fenstr)
 
void setFENInitialPos ()
 
bool playGameMoveSeries (std::string const &coordmoves)
 all moves in a single string
 
bool playPGNMoves (std::string const &sPGNMoveList)
 apply move, it will change the current board by updating the move played it will also add the new board to the game positions list
 
void revertGameMove (std::string const &reason)
 required for Winboard protocol, not supported in UCI (except debug)
 
void setResult (gameResult_t gr)
 
gameResult_t getResult () const
 
bool isExpecting (std::string const &s) const
 
void setExpecting (std::string const &s)
 
std::string const & getExpecting () const
 
bBoardgetCurrentPosition ()
 
void setLevel (bLevel const &l)
 
bLevelgetLevel ()
 
positions_tgetPositions ()
 
void setPlayerName (std::string const &n)
 
void DoSearch ()
 Start search thread and exit in case of batch mode, will wait until end of search.
 
void AbortSearch ()
 
void WaitForSearchEnd ()
 Called in separate thread, sure to terminate normally.
 
bScore EvalForPlayer (bBoard const &b, gameResult_t gr)
 
int64_t DoPerftCommand (depth_t const d)
 do perft search using SearchPerft algorithm at depth
 
int64_t DoPerft (bSearchAlgorithm &sa, depth_t const d)
 do perft search at depth in case of Perft algorithm, temporarily set evaltype to None
 
bMove getEpdMoveInPosition (bFen const &fen)
 do actual epd position test
 
void setStandardPgn (bool const l)
 
constexpr bool isStandardPgn () const
 
void setSearching (bool const l)
 
constexpr bool isSearching () const
 
 operator std::string () const
 
- Public Member Functions inherited from bConfigurableGame
 bConfigurableGame ()
 
virtual ~bConfigurableGame ()
 
 bConfigurableGame (bConfigurableGame const &)=delete
 
bConfigurableGameoperator= (bConfigurableGame const &)=delete
 
 bConfigurableGame (bConfigurableGame &&)=delete
 
bConfigurableGameoperator= (bConfigurableGame &&)=delete
 
void setAlgorithm (std::string const &alg)
 
bSearchAlgorithmgetAlgorithm () const
 
void setEval (std::string const &e)
 
bPositionEvaluationgetEval () const
 

Static Public Member Functions

static std::string getResult (gameResult_t gr)
 

Detailed Description

game representation, singleton

Definition at line 20 of file game.h.

Constructor & Destructor Documentation

◆ bGame() [1/3]

bGame::bGame ( )

Definition at line 15 of file game.cpp.

Referenced by bGame(), bGame(), operator=(), and operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~bGame()

bGame::~bGame ( )
inlineoverride

Definition at line 23 of file game.h.

◆ bGame() [2/3]

bGame::bGame ( bGame const & )
delete
+ Here is the call graph for this function:

◆ bGame() [3/3]

bGame::bGame ( bGame && )
delete
+ Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/2]

bGame & bGame::operator= ( bGame const & )
delete
+ Here is the call graph for this function:

◆ operator=() [2/2]

bGame & bGame::operator= ( bGame && )
delete
+ Here is the call graph for this function:

◆ newGame()

void bGame::newGame ( )

Definition at line 24 of file game.cpp.

Referenced by bGame(), cmd_bench::execute(), cmd_load::execute(), cmd_new::execute(), cmd_ucinewgame::execute(), getEpdMoveInPosition(), main(), bEpd::parsePerftPosition(), and bel_debug::run_bench().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFEN()

void bGame::setFEN ( std::string const & fenstr)

Definition at line 54 of file game.cpp.

Referenced by cmd_position::execute(), cmd_setboard::execute(), getEpdMoveInPosition(), bEpd::parsePerftPosition(), and bel_debug::run_bench().

+ Here is the caller graph for this function:

◆ setFENInitialPos()

void bGame::setFENInitialPos ( )

Definition at line 46 of file game.cpp.

Referenced by cmd_bench::execute(), cmd_load::execute(), cmd_new::execute(), cmd_position::execute(), cmd_ucinewgame::execute(), main(), and bel_debug::run_bench().

+ Here is the caller graph for this function:

◆ playGameMoveSeries()

bool bGame::playGameMoveSeries ( std::string const & coordmoves)

all moves in a single string

Returns
false if one move cannot be played

Definition at line 197 of file game.cpp.

+ Here is the call graph for this function:

◆ playPGNMoves()

bool bGame::playPGNMoves ( std::string const & sPGNMoveList)

apply move, it will change the current board by updating the move played it will also add the new board to the game positions list

Returns
true if at least a single move has been applied to position

Definition at line 248 of file game.cpp.

Referenced by cmd_load::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revertGameMove()

void bGame::revertGameMove ( std::string const & reason)

required for Winboard protocol, not supported in UCI (except debug)

Definition at line 286 of file game.cpp.

Referenced by cmd_again::execute(), cmd_remove::execute(), and cmd_undo::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResult() [1/2]

std::string bGame::getResult ( gameResult_t gr)
static

Definition at line 179 of file game.cpp.

Referenced by engineInterface::sendResult(), and XboardMode::sendResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setResult()

void bGame::setResult ( gameResult_t gr)

Definition at line 187 of file game.cpp.

Referenced by revertGameMove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResult() [2/2]

gameResult_t bGame::getResult ( ) const
inline

Definition at line 41 of file game.h.

Referenced by newGame(), setResult(), and WaitForSearchEnd().

+ Here is the caller graph for this function:

◆ isExpecting()

bool bGame::isExpecting ( std::string const & s) const
inline
Todo
improve by redirecting App().bout

Definition at line 44 of file game.h.

◆ setExpecting()

void bGame::setExpecting ( std::string const & s)
inline

Definition at line 47 of file game.h.

Referenced by cmd_expect::execute(), and cmd_perft::execute().

+ Here is the caller graph for this function:

◆ getExpecting()

std::string const & bGame::getExpecting ( ) const
inline

Definition at line 49 of file game.h.

◆ getCurrentPosition()

bBoard & bGame::getCurrentPosition ( )
inline
Todo
check why copy constructor is called, check if we should return anything else but positions.back()

Definition at line 54 of file game.h.

Referenced by DoPerft(), DoSearch(), bel_debug::execute(), cmd_bd::execute(), cmd_eval::execute(), cmd_usermove::execute(), getEpdMoveInPosition(), bEpd::parseEpdPosition(), bEpd::parseSTSPosition(), playPGNMoves(), revertGameMove(), setPlayerName(), and WaitForSearchEnd().

+ Here is the caller graph for this function:

◆ setLevel()

void bGame::setLevel ( bLevel const & l)
inline

Definition at line 57 of file game.h.

Referenced by cmd_go::execute().

+ Here is the caller graph for this function:

◆ getLevel()

◆ getPositions()

positions_t & bGame::getPositions ( )
inline

Definition at line 61 of file game.h.

◆ setPlayerName()

void bGame::setPlayerName ( std::string const & n)

Definition at line 62 of file game.cpp.

Referenced by cmd_name::execute(), and cmd_UCI_Opponent::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoSearch()

void bGame::DoSearch ( )

Start search thread and exit in case of batch mode, will wait until end of search.

in case of batch mode, do not start separate thread for searching

Todo
allow for cancel search with ? / stop command

Definition at line 75 of file game.cpp.

Referenced by cmd_go::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AbortSearch()

void bGame::AbortSearch ( )

Definition at line 98 of file game.cpp.

Referenced by cmd_questionmark::execute(), and cmd_stop::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WaitForSearchEnd()

void bGame::WaitForSearchEnd ( )

Called in separate thread, sure to terminate normally.

Todo
handle sending result here

Definition at line 106 of file game.cpp.

Referenced by DoSearch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EvalForPlayer()

bScore bGame::EvalForPlayer ( bBoard const & b,
gameResult_t gr )

Definition at line 174 of file game.cpp.

Referenced by cmd_eval::execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoPerftCommand()

int64_t bGame::DoPerftCommand ( depth_t const d)

do perft search using SearchPerft algorithm at depth

Definition at line 129 of file game.cpp.

Referenced by bEpd::parsePerftPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoPerft()

int64_t bGame::DoPerft ( bSearchAlgorithm & sa,
depth_t const d )

do perft search at depth in case of Perft algorithm, temporarily set evaltype to None

Definition at line 139 of file game.cpp.

Referenced by DoPerftCommand(), cmd_perft::execute(), and bel_debug::run_bench().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEpdMoveInPosition()

bMove bGame::getEpdMoveInPosition ( bFen const & fen)

do actual epd position test

Definition at line 300 of file game.cpp.

+ Here is the call graph for this function:

◆ setStandardPgn()

void bGame::setStandardPgn ( bool const l)
inline

Definition at line 76 of file game.h.

Referenced by cmd_export::execute(), cmd_game::execute(), and cmd_save::execute().

+ Here is the caller graph for this function:

◆ isStandardPgn()

bool bGame::isStandardPgn ( ) const
inlineconstexpr

Definition at line 78 of file game.h.

Referenced by operator std::string().

+ Here is the caller graph for this function:

◆ setSearching()

void bGame::setSearching ( bool const l)
inline

Definition at line 80 of file game.h.

Referenced by bSearchAlgorithm::StartSearch(), and bSearchAlgorithm::StopSearch().

+ Here is the caller graph for this function:

◆ isSearching()

bool bGame::isSearching ( ) const
inlineconstexpr

Definition at line 82 of file game.h.

◆ operator std::string()

bGame::operator std::string ( ) const
Todo
Look at using stream and << operator instead of std::string

Definition at line 353 of file game.cpp.

+ Here is the call graph for this function: