Belofte version 2.2.0
A promising chess program using the UCI or Winboard interface
bSearchAlgorithm Class Referenceabstract

#include <search.h>

+ Inheritance diagram for bSearchAlgorithm:
+ Collaboration diagram for bSearchAlgorithm:

Public Member Functions

 bSearchAlgorithm (std::string const &s)
 
 ~bSearchAlgorithm () override
 
 bSearchAlgorithm (bSearchAlgorithm const &)=delete
 
 bSearchAlgorithm (bSearchAlgorithm &&)=delete
 
bSearchAlgorithmoperator= (bSearchAlgorithm const &)=delete
 
bSearchAlgorithmoperator= (bSearchAlgorithm &&)=delete
 
constexpr int64_t getNodes () const
 
constexpr int64_t getNonLeafNodes () const
 
void StartSearch (bScore const sc)
 
void StopSearch ()
 
void InterruptSearch ()
 
void SearchBestMove (bBoard &b, bMoveList &ml)
 Generic search, will call (non-)recursive method per algorithm only when there are moves to be played.
 
void sendInfoSearching (bBoard const &b, depth_t const nDepth, std::string const &comment) const
 
bScore sendInfoSearching (bBoard const &b, depth_t const nDepth, std::string const &comment, bScore const sc) const
 
bScore RetrieveBoardEvaluation (bBoard &b, gameResult_t const gr, bool const bRecalcFirst) const
 Get score of board, eventually from cache.
 
bScore RetrieveBoardEvaluationForWhite (bBoard &b, gameResult_t const gr, bool const bRecalcFirst) const
 Get score of board, eventually from cache, from whites view.
 
constexpr bool isNoBench () const
 
constexpr bool isBench () const
 
void setBench ()
 
void clearBench ()
 
 operator std::string () const &
 
- Public Member Functions inherited from TimedExecution
 TimedExecution ()
 implementation of timing functions
 
virtual ~TimedExecution ()=default
 
std::string getDuration () const
 
long long getDurationMicroSec () const
 

Public Attributes

int64_t m_leafnodes = 0LL
 
int64_t m_nonleafnodes = 0LL
 
bool m_iterativesearch = false
 

Protected Member Functions

virtual bScore CalcBestMove (bBoard &b, bMoveList &ml)=0
 
void CheckIfAbortingSearch () const
 
void adjustMaxSearchedDepth (depth_t const nDepth)
 
constexpr depth_t getMaxSearchedDepth () const
 
void initMaxSearchedDepth ()
 
void setLevel (bLevel *l)
 
bLevelgetLevel ()
 
void sendInfoCurrMove (bBoard const &b, depth_t const nCurDepth, bMove const &m, movenum_t const moveid) const
 
- Protected Member Functions inherited from TimedExecution
void ClockStart ()
 
void ClockEnd ()
 
long long getDurationSec () const
 
long long getDurationMilliSec () const
 

Additional Inherited Members

- Static Public Member Functions inherited from TimedExecution
static void sleep_ms (unsigned long ms)
 Class static function Pause execution for a number of ms.
 

Detailed Description

Definition at line 91 of file search.h.

Constructor & Destructor Documentation

◆ bSearchAlgorithm() [1/3]

◆ ~bSearchAlgorithm()

bSearchAlgorithm::~bSearchAlgorithm ( )
inlineoverride

Definition at line 100 of file search.h.

◆ bSearchAlgorithm() [2/3]

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

◆ bSearchAlgorithm() [3/3]

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

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ getNodes()

int64_t bSearchAlgorithm::getNodes ( ) const
inlineconstexpr

Definition at line 109 of file search.h.

Referenced by bGame::DoPerft().

+ Here is the caller graph for this function:

◆ getNonLeafNodes()

int64_t bSearchAlgorithm::getNonLeafNodes ( ) const
inlineconstexpr

Definition at line 111 of file search.h.

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

+ Here is the caller graph for this function:

◆ StartSearch()

void bSearchAlgorithm::StartSearch ( bScore const sc)

Definition at line 211 of file search.cpp.

Referenced by SearchBestMove().

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

◆ StopSearch()

void bSearchAlgorithm::StopSearch ( )

Definition at line 231 of file search.cpp.

Referenced by SearchBestMove().

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

◆ InterruptSearch()

void bSearchAlgorithm::InterruptSearch ( )
inline

Definition at line 116 of file search.h.

Referenced by bGame::AbortSearch().

+ Here is the caller graph for this function:

◆ SearchBestMove()

void bSearchAlgorithm::SearchBestMove ( bBoard & b,
bMoveList & ml )

Generic search, will call (non-)recursive method per algorithm only when there are moves to be played.

Parameters
binitial board
mlmovelist of this position
Todo
Add debug manipulator

Definition at line 18 of file search.cpp.

Referenced by bGame::DoPerft(), bGame::getEpdMoveInPosition(), and bGame::WaitForSearchEnd().

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

◆ sendInfoSearching() [1/2]

void bSearchAlgorithm::sendInfoSearching ( bBoard const & b,
depth_t const nDepth,
std::string const & comment ) const

Definition at line 250 of file search.cpp.

Referenced by SearchBestMove().

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

◆ sendInfoSearching() [2/2]

bScore bSearchAlgorithm::sendInfoSearching ( bBoard const & b,
depth_t const nDepth,
std::string const & comment,
bScore const sc ) const

Definition at line 264 of file search.cpp.

+ Here is the call graph for this function:

◆ RetrieveBoardEvaluation()

bScore bSearchAlgorithm::RetrieveBoardEvaluation ( bBoard & b,
gameResult_t const gr,
bool const bRecalcFirst ) const

Get score of board, eventually from cache.

Parameters
bboard
grprevious gameresult
bRecalcFirstrecalculate pieces first
Returns
score of board, either from cache, from gr or caclulated

Definition at line 302 of file search.cpp.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchEvalPosOnly::CalcBestMove(), and SearchAlphaBeta::Quiescence().

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

◆ RetrieveBoardEvaluationForWhite()

bScore bSearchAlgorithm::RetrieveBoardEvaluationForWhite ( bBoard & b,
gameResult_t const gr,
bool const bRecalcFirst ) const

Get score of board, eventually from cache, from whites view.

Parameters
bboard
grprevious gameresult
bRecalcFirstrecalculate pieces first
Returns
score of board, either from cache, from gr or caclulated

Definition at line 323 of file search.cpp.

Referenced by SearchMiniMax::CalcBestMove().

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

◆ isNoBench()

bool bSearchAlgorithm::isNoBench ( ) const
inlineconstexpr

Definition at line 132 of file search.h.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchMiniMax::CalcBestMove(), SearchAlphaBeta::Quiescence(), and SearchBestMove().

+ Here is the caller graph for this function:

◆ isBench()

bool bSearchAlgorithm::isBench ( ) const
inlineconstexpr

Definition at line 134 of file search.h.

Referenced by SearchMiniMax::CalcBestMove().

+ Here is the caller graph for this function:

◆ setBench()

void bSearchAlgorithm::setBench ( )
inline

Definition at line 136 of file search.h.

Referenced by bGame::DoPerft().

+ Here is the caller graph for this function:

◆ clearBench()

void bSearchAlgorithm::clearBench ( )
inline

Definition at line 138 of file search.h.

Referenced by bGame::DoPerft().

+ Here is the caller graph for this function:

◆ operator std::string()

bSearchAlgorithm::operator std::string ( ) const &
inline

Definition at line 141 of file search.h.

◆ CalcBestMove()

virtual bScore bSearchAlgorithm::CalcBestMove ( bBoard & b,
bMoveList & ml )
protectedpure virtual

Implemented in SearchAlphaBeta, SearchBruteForce, SearchEvalPosOnly, SearchMiniMax, SearchPerft, and SearchRandom.

Referenced by SearchBestMove().

+ Here is the caller graph for this function:

◆ CheckIfAbortingSearch()

void bSearchAlgorithm::CheckIfAbortingSearch ( ) const
protected
Todo
: limit calls to getDurationMilliSec

Definition at line 223 of file search.cpp.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchEvalPosOnly::CalcBestMove(), SearchMiniMax::CalcBestMove(), and SearchAlphaBeta::Quiescence().

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

◆ adjustMaxSearchedDepth()

void bSearchAlgorithm::adjustMaxSearchedDepth ( depth_t const nDepth)
inlineprotected

◆ getMaxSearchedDepth()

depth_t bSearchAlgorithm::getMaxSearchedDepth ( ) const
inlineconstexprprotected

Definition at line 154 of file search.h.

◆ initMaxSearchedDepth()

void bSearchAlgorithm::initMaxSearchedDepth ( )
inlineprotected

Definition at line 156 of file search.h.

Referenced by SearchBestMove().

+ Here is the caller graph for this function:

◆ setLevel()

void bSearchAlgorithm::setLevel ( bLevel * l)
inlineprotected

Definition at line 159 of file search.h.

Referenced by StartSearch().

+ Here is the caller graph for this function:

◆ getLevel()

bLevel * bSearchAlgorithm::getLevel ( )
inlineprotected

Definition at line 161 of file search.h.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchMiniMax::CalcBestMove(), SearchPerft::CalcBestMove(), SearchAlphaBeta::Quiescence(), SearchBestMove(), and StartSearch().

+ Here is the caller graph for this function:

◆ sendInfoCurrMove()

void bSearchAlgorithm::sendInfoCurrMove ( bBoard const & b,
depth_t const nCurDepth,
bMove const & m,
movenum_t const moveid ) const
protected

Member Data Documentation

◆ m_leafnodes

◆ m_nonleafnodes

◆ m_iterativesearch