11#pragma GCC diagnostic push
12#pragma GCC diagnostic ignored "-Weffc++"
21#pragma GCC diagnostic pop
29 m_pgnTags[
"Site"] =
"";
31 m_pgnTags[
"Round"] =
"";
34 m_pgnTags[
"Result"] =
getResult(m_result);
36 m_optTags[
"eloWhite"] =
"";
37 m_optTags[
"eloBlack"] =
"";
45 m_positions.emplace_back(
bFen(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"));
46 m_optTags.erase(
"SetUp");
47 m_optTags.erase(
"FEN");
53 m_positions.emplace_back(
bFen(fenstr));
54 m_optTags[
"SetUp"] =
"1";
55 m_optTags[
"FEN"] = fenstr;
61 m_pgnTags[
"White"] = n;
63 m_pgnTags[
"Black"] = n;
73 if (
App().m_reader.isBatchMode()) {
114 }
catch (...) {
throw;
133 bLevel oldLevel = m_level;
135 m_level.setDepthCommand(d);
137 std::string sAlgName =
getAlgorithm()->operator std::string();
138 std::string sEval =
getEval()->operator std::string();
140 if (sAlgName ==
"Perft")
setEval(
"None");
154 }
catch (...) {
throw;
160 if (sAlgName ==
"Perft")
setEval(sEval);
182 m_pgnTags[
"Result"] =
getResult(m_result);
193 return std::all_of(vstrings.begin(), vstrings.end(),
194 [
this](std::string
const& s){ return this->playGameMove(bCoordMove(s)); });
209 for (
movenum_t moveid = 1; moveid <= n_moves; ++moveid) {
212 if (cm == coordmove) {
217 m_positions.push_back(newboard);
239 if (m_positions.size() > 1) {
240 m_positions.pop_back();
267 }
catch (...) {
throw;
275std::string bGame::movesinpgnformat()
const
277 std::stringstream sMoves;
278 std::stringstream sMovePrefix;
280 if (m_positions.size() > 1) {
281 if (m_positions[0].blackToMove()) {
282 sMovePrefix << m_positions[0].getMoveNumber() <<
"... ";
285 for (
unsigned int i = 1; i < m_positions.size(); ++i) {
286 bBoard newboard(m_positions[i]);
287 bBoard ob(m_positions[i - 1]);
288 if (newboard.getMove()) {
289 if (ob.whiteToMove()) {
290 sMovePrefix << newboard.getMoveNumber() <<
". ";
292 bPgnMove pm(ob, newboard.getMove());
293 sMoves << sMovePrefix.str() << pm <<
" ";
304bGame::operator std::string()
const
306 std::string sGameHeader =
"";
309 for (
auto const& x : m_pgnTags) {
310 sGameHeader +=
"[" + x.first +
" \"" + x.second +
"\"]" +
"\n";
314 for (
auto const& x : m_optTags) {
315 if (x.second.size()) {
316 sGameHeader +=
"[" + x.first +
" \"" + x.second +
"\"]" +
"\n";
319 return sGameHeader +
"\n" + movesinpgnformat();
engineInterface * AppEI()
This is the main include file, needs to be included before any other include.
outputWriter sout
normal output
int64_t getConfig(std::string const &s, int64_t v)
constexpr bool whiteToMove() const
constexpr bScore minimizing() const
constexpr fromto_t getFromTo() const
boardInfo_t applyMove(bMove const &m) override
modification of board move is kept on previous board newboard does not have move stored and has flag ...
void setMove(bmove_t const bmt)
void calcGameStage()
calculate stage of game to assist in evaluation
void setEval(std::string const &e)
bSearchAlgorithm * getAlgorithm() const
bPositionEvaluation * getEval() const
simple coordmove, with 4 characters, or 5 characters in case of promotion mostly used for interface
bMove getEpdMoveInPosition(bFen const &fen)
do actual epd position test
bScore EvalForPlayer(bBoard const &b)
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...
void setResult(gameResult_t gr)
void setPlayerName(std::string const &n)
int64_t DoPerft(bSearchAlgorithm &sa, depth_t const d)
do perft search at depth in case of Perft algorithm, temporarily set evaltype to None
void WaitForSearchEnd()
Called in separate thread, sure to terminate normally.
void revertGameMove(std::string const &reason)
required for Winboard protocol, not supported in UCI (except debug)
void DoSearch()
Start search thread and exit in case of batch mode, will wait until end of search.
bool playGameMoveSeries(std::string const &coordmoves)
all moves in a single string
void setFEN(std::string const &fenstr)
int64_t DoPerftCommand(depth_t const d)
do perft search using SearchPerft algorithm at depth
gameResult_t getResult() const
bBoard & getCurrentPosition()
movenum_t generateMoves(bBasicBoard const &b)
generate moves if not yet generated
constexpr movenum_t getBestMoveId() const
constexpr movenum_t getNumberOfMoves() const
static bool isDrawResult(gameResult_t const gr)
virtual bScore getEvaluation(bBoard const &b) const
get final score or 0
constexpr int64_t getNodes() const
void SearchBestMove(bBoard &b, bMoveList &ml)
Generic search, will call (non-)recursive method per algorithm only when there are moves to be played...
static constexpr bool isDrawScore(bScore const score)
static constexpr bool isUndefinedScore(bScore const score)
virtual void sendResult(bBoard const &b, gameResult_t const gr) const
virtual void sendMove(bBoard &b, bMove const &m)
virtual void sendError(std::string const &error, std::string const &description)
void setLevel(int const l)
constexpr bScore SCORE_MATE
enum gameResult gameResult_t
stringList const stringSplit(std::string src, std::string const &delim)
Split delimited long string into a vector.
std::string currentDate()