10bEpd::operator std::string()
const
13 ss << m_Fen <<
" => ";
14 for (
const auto &m : m_Keys)
15 ss <<
"[" << m.first <<
"] = " << m.second <<
"; ";
30 if (sFenSgmt.size() >= 4) {
33 if (sPerftCommaElem.size() > 1) {
34 sFenSgmt[3] = sPerftCommaElem[0];
37 m_Fen = sFenSgmt[0] +
" " + sFenSgmt[1] +
" "
38 + sFenSgmt[2] +
" " + sFenSgmt[3];
39 sFenSgmt.erase(sFenSgmt.begin(), sFenSgmt.begin() + 4);
43 m_Fen +=
" " + sFenSgmt[0];
44 sFenSgmt.erase(sFenSgmt.begin());
51 m_Fen +=
" " + sFenSgmt[0];
52 sFenSgmt.erase(sFenSgmt.begin());
58 if (sPerftCommaElem.size() > 1) {
60 std::stringstream sPerftSection;
61 for (
unsigned long i = 1; (i <
EPD_PERFTMAXDEPTH) && (sPerftCommaElem.size() > i); ++i) {
63 << sPerftCommaElem[i] <<
";";
65 sFenSgmt.push_back(sPerftSection.str());
69 std::string sCmd =
";" + std::accumulate(sFenSgmt.begin(), sFenSgmt.end(), std::string(),
70 [](std::string result, std::string sElem) {
71 return std::move(result) + std::move(sElem) +
" ";
76 for (
auto it = sCmdSgmt.begin(); it != sCmdSgmt.end(); ++it) {
83 for (
const auto &sElem : sCmdSgmt) {
84 if (sElem.length() > 0) {
86 if (sElem.substr(0,3) ==
"id=") {
106 if (m_Keys.find(tag) != m_Keys.end()) {
131 if (m_Keys.find(sOp) != m_Keys.end()) { bPerft =
true;
break; }
145 if (m_Keys.find(
"c0") != m_Keys.end()) {
148 if (c0Parts.size() > 1) c0Parts.erase(c0Parts.begin());
149 if (!c0Parts.empty()) {
153 for (
auto it = sC0Segment.begin(); it != sC0Segment.end(); ++it) {
160 }
else if (m_Keys.find(
"bm") == m_Keys.end()) {
165 if (m_Keys.find(
"bm") != m_Keys.end()) {
168 for (
auto it = sMoves.begin(); it != sMoves.end(); ++it) {
171 if (moveValues.find(sMove) == moveValues.end()) {
173 moveValues.insert(std::make_pair(sMove,10));
178 bMove m(
Game()->getEpdMoveInPosition(fen));
191 bMove m(
Game()->getEpdMoveInPosition(fen));
208 if (m_Keys.find(
"bm") != m_Keys.end()) {
210 if (std::any_of(sMoves.begin(), sMoves.end(),
211 [m](std::string
const& sm)
212 { return m == sm; })) {
215 }
else if (m_Keys.find(
"am") != m_Keys.end()) {
218 if (std::none_of(sMoves.begin(), sMoves.end(),
219 [m](std::string
const& sm)
220 { return m == sm; })) {
225 App().
bout <<
"found : " << m <<
" - ";
232 if (moveValues.find(ms) != moveValues.end()) {
233 return moveValues[ms];
251 if (m_Keys.find(sOp) != m_Keys.end()) {
256 << std::string(*
this);
278 for (
const auto &sElem : sParams) s += sElem +
" ";
285#pragma GCC diagnostic push
286#pragma GCC diagnostic ignored "-Weffc++"
292 handleFile(sFileName);
298 if (!sParams.empty()) {
299 handleFile(sParams[0]);
304#pragma GCC diagnostic pop
309 if (m_sEpdFile.is_open()) m_sEpdFile.close();
314void bEpdFile::handleFile(std::string
const& sFileName)
316 if (sFileName.empty()) {
319 m_sEpdFile.open(sFileName.c_str(), std::ios::in );
320 if (!m_sEpdFile.is_open()) {
338 while(getline(m_sEpdFile,line)) {
339 if ((line.length() < 6)
340 || (line.substr(0,1) ==
";")
341 || (line.substr(0,1) ==
"#")) {
347 std::string sID =
getTag(
"id");
349 App().
bout <<
"Error : " << std::string(*
this);
352 App().
bout <<
"Perft OK : " << std::string(*
this);
361 App().
bout <<
"score : " << std::setw(2) << sc
362 <<
" Total : " << std::setw(4) << nGoods;
363 if (!sID.empty())
App().
bout <<
" (" << sID <<
")";
374 if (!sID.empty())
App().
bout <<
" (" << sID <<
")";
378 App().
bout <<
"No move found : " << std::string(*
this);
388 App().
bout <<
"Result " << std::setprecision(3) << std::defaultfloat
396 App().
bout <<
" = " << std::setprecision(4) << std::defaultfloat
397 <<
static_cast<float>(nGoods * 100.0) /
static_cast<float>(nTotal) <<
"%\n";
engineInterface * AppEI()
This is the main include file, needs to be included before any other include.
constexpr bmove_t getBMoveT() const
bEpdFile(std::string const &sFileName, epdTest_t const typeOfTest)
virtual ~bEpdFile() override
virtual bEpdResult parse() override
Main epd parser for multiple lines of epd file Will calculate a total score and some statistics.
int translateSTSResult(bPgnMove const &m, bEpdMoveValues &moveValues)
std::string const getTag(std::string const &tag)
virtual bEpdResult parse()
parse any epd position
bEpdResult parseEpdPosition(bFen const &fen)
do actual epd position test
bEpdResult parseSTSPosition(bFen const &fen)
bEpdResult translateEpdResult(bPgnMove const &m)
check move found against epd line m_Keys, change level before starting search am avoid-moves bm best-...
void setPos(std::string const &s)
EPD pos is fen-board fen-tomove fen-castling fen-ep [50moves] [move#] cmdsection* cmdsection is bm Sa...
bEpd(epdTest_t const typeOfTest)
bEpdResult parsePerftPosition(bFen const &fen)
check perft result for different depths D[1-99] # perft test - nodes
epdTest_t getTestType() const
void setScore(int const s)
bEpdPos(std::string const &sEpd, epdTest_t const typeOfTest)
void setFEN(std::string const &fenstr)
int64_t DoPerftCommand(depth_t const d)
do perft search using SearchPerft algorithm at depth
bBoard & getCurrentPosition()
PgnMove is for user-interface only.
virtual void sendDebug(int const l, std::string const &info)
virtual void sendError(std::string const &error, std::string const &description)
std::vector< std::string > bEpdParamList
enum tEpdTestType epdTest_t
std::map< std::string, int > bEpdMoveValues
#define EPD_PERFTMAXDEPTH
std::string alltrim(std::string s, std::string const &delim=" ")
trim left and right spaces or delim from string
std::pair< std::string, std::string > decompose(std::string const &src, std::string const &delim)
Split delimited long string into a pair based on delimiter e.g.
std::string to_string(int16_t value)
std::to_string not compatible on Mac OS (Apple LLVM version 5.0) provide generic utility function
stringList const stringSplit(std::string src, std::string const &delim)
Split delimited long string into a vector.
std::vector< std::string > stringList
bool is_number(std::string const &s)