24 ss <<
"Searching started: " << this->
operator std::string() <<
" "
25 <<
getLevel()->operator std::string()
27 m_appei->sendInfoSearchStart(ss.str());
41 m_appei->sendInfo(
"engine should not have started searching as position is final");
42 m_appei->sendResult(b, gr);
49 SearchBestMoveIterative(b, ml);
55 }
catch (...) {
throw;
88 std::string sPreviousBestMove;
89 std::string sNewBestMove;
91 while (iCurrentDepth <=
getLevel()->getMaxDepth()) {
95 m_appei->sendInfo(
"ItSearch started at" + sDepthLBL);
104 #if !defined(NO_NPS_LOG)
106 if (nDuration < 1) nDuration = 1;
107 long nNPS = nNodes * 1000000 / nDuration;
108 m_appei->sendInfoDepth(iCurrentDepth, m_maxDepth, nNodes,
static_cast<int>(nNPS));
110 m_appei->sendInfoDepth(iCurrentDepth, m_maxDepth, nNodes, 0);
117 if (sNewBestMove == sPreviousBestMove) {
118 m_appei->sendInfo(
"ItSearch Best move unchanged: " + sNewBestMove + sDepthLBL);
119 }
else if (sPreviousBestMove.empty()) {
120 m_appei->sendInfo(
"ItSearch Best move found: " + sNewBestMove + sDepthLBL);
122 m_appei->sendInfo(
"ItSearch Best move updated: " + sNewBestMove + sDepthLBL);
126 if (!sNewBestMove.empty() && sNewBestMove !=
static_cast<std::string
>(cm)) {
127 m_appei->sendInfo(
"ItSearch Inconsistency with PV: " +
static_cast<std::string
>(cm) +
" vs " + sNewBestMove + sDepthLBL);
129 }
catch (
const searchAbortedException&) {
130 if (iCurrentDepth < 2) {
134 if ((ml.
curmoveid > 2) && (n_moves > 1)) {
138 if (sPreviousBestMove !=
static_cast<std::string
>(cm)) {
139 sendInfoSearching(b, 0,
"ItSearch partial search best move update: " +
static_cast<std::string
>(cm) + sDepthLBL);
149 if (sPreviousBestMove !=
static_cast<std::string
>(cm)) {
150 sendInfoSearching(b, 0,
"ItSearch initial search best move update: " +
static_cast<std::string
>(cm) + sDepthLBL);
159 }
catch (...) {
throw;
179 if (!sPreviousBestMove.empty()
180 && (sNewBestMove != sPreviousBestMove)) {
184 m_appei->sendInfo(
"ItSearch increase time for search");
189 sendInfoSearching(b, 0,
"ItSearch not enough time for more depth" + sDepthLBL +
" done", score);
191 }
else if (sPreviousBestMove.empty() && !sNewBestMove.empty()) {
193 sPreviousBestMove = sNewBestMove;
194 }
else if (sNewBestMove != sPreviousBestMove) {
195 sendInfoSearching(b, 0,
"ItSearch bestmove updated" + sDepthLBL +
" done", score);
196 sPreviousBestMove = sNewBestMove;
198 sendInfoSearching(b, 0,
"ItSearch searching ended at" + sDepthLBL +
" done", score);
201 if (iCurrentDepth <
getLevel()->getMaxDepth()) {
202 dumpMoveList(ml, iCurrentDepth);
240void bSearchAlgorithm::dumpMoveList(
bMoveList const& ml,
depth_t const iDepth)
const
242 std::stringstream ss;
251 depth_t const nDepth, std::string
const& comment)
const
253 if (nDepth <= m_postlevel) {
255 m_appei->sendInfoSearching(b, nDepth, m_maxDepth, comment,
SCORE_UNDEFINED,
265 depth_t const nDepth, std::string
const& comment,
268 if (nDepth <= m_postlevel) {
270 m_appei->sendInfoSearching(b, nDepth, m_maxDepth,
274 m_appei->sendInfoSearching(b, nDepth, m_maxDepth,
287 if (nCurDepth <= m_postlevel) {
288 m_appei->sendInfoCurrMove(b, nCurDepth,
313 return m_evalptr->getEvaluation(b, gr) * b.
minimizing();
334 return m_evalptr->getEvaluation(b, gr);
engineInterface * AppEI()
This is the main include file, needs to be included before any other include.
std::string getDuration() const
long long getDurationMilliSec() const
long long getDurationMicroSec() const
outputWriter sout
normal output
constexpr bool whiteToMove() const
constexpr bScore minimizing() const
void calcMinorPieces(bool const bForceRecalc)
Recalculate minor pieces, used for evaluation and end of game condition in case of less than 5 pieces...
movesequence_t const & getVariation() const
void calcGameStage()
calculate stage of game to assist in evaluation
void setPreviousMoves(movesequence_t const &v)
bPositionEvaluation * getEval() const
void setSearching(bool const l)
void setMoreTimeRequired()
increase gradually the allowed time for move, first move to max time for move, then move to abort tim...
void setSearchDepth(depth_t const d)
movenum_t generateMoves(bBasicBoard const &b)
generate moves if not yet generated
constexpr bScore getBestMoveScore() const
constexpr movenum_t getBestMoveId() const
constexpr movenum_t getNumberOfMoves() const
bool atLeastOneMovePossible(bBasicBoard &b)
see if at least one move can be played e.g.
constexpr movenum_t getNumberOfQSMoves() const
void setBestMoveId(movenum_t const n)
void sortMoves(bool const bFastSort)
sort moves and update bestmove id if less than 5 moves, sort all if more than 5 moves,...
static bScore resultToScoreFlag(gameResult_t const gr)
Class static function convert all draw scores to SCORE_THEORETIC_DRAW.
static gameResult_t gameEndedResult(bBoard const &b)
Class static function See if board is in finite state, meaning game is ended.
void StartSearch(bScore const sc)
void sendInfoCurrMove(bBoard const &b, depth_t const nCurDepth, bMove const &m, movenum_t const moveid) const
bScore RetrieveBoardEvaluationForWhite(bBoard &b, gameResult_t const gr, bool const bRecalcFirst) const
Get score of board, eventually from cache, from whites view.
void initMaxSearchedDepth()
constexpr bool isNoBench() const
void SearchBestMove(bBoard &b, bMoveList &ml)
Generic search, will call (non-)recursive method per algorithm only when there are moves to be played...
bScore RetrieveBoardEvaluation(bBoard &b, gameResult_t const gr, bool const bRecalcFirst) const
Get score of board, eventually from cache.
void CheckIfAbortingSearch() const
void sendInfoSearching(bBoard const &b, depth_t const nDepth, std::string const &comment) const
virtual bScore CalcBestMove(bBoard &b, bMoveList &ml)=0
constexpr bScore realScore() const
virtual void sendInfo(std::string const &info)
enum gameResult gameResult_t
constexpr bScore SCORE_UNDEFINED
constexpr bScore SCORE_INFINITE
std::string to_string(int16_t value)
std::to_string not compatible on Mac OS (Apple LLVM version 5.0) provide generic utility function