Belofte version 2.1.9
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 playGameMove (bCoordMove const &coordmove)
 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
 
bool playGameMoveSeries (std::string const &coordmoves)
 all moves in a single string
 
void revertGameMove (std::string const &reason)
 required for Winboard protocol, not supported in UCI (except debug)
 
std::string getResult (gameResult_t gr) const
 
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)
 
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
 
 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
 

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_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 50 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 42 of file game.cpp.

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

+ Here is the caller graph for this function:

◆ playGameMove()

bool bGame::playGameMove ( bCoordMove const & coordmove)

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

Definition at line 201 of file game.cpp.

Referenced by WaitForSearchEnd().

+ Here is the call graph for this function:
+ 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 189 of file game.cpp.

+ Here is the call 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 237 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) const

Definition at line 171 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 179 of file game.cpp.

Referenced by playGameMove(), and 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(), playGameMove(), 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 58 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 71 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 90 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 98 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)

Definition at line 166 of file game.cpp.

Referenced by cmd_eval::execute(), and playGameMove().

+ 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 121 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 131 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 251 of file game.cpp.

+ Here is the call graph for this function:

◆ operator std::string()

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

Definition at line 304 of file game.cpp.