Belofte version 2.2.0
A promising chess program using the UCI or Winboard interface
bMoveList Class Reference

#include <movelist.h>

Public Member Functions

 bMoveList ()
 
 bMoveList (bMoveList &ml)
 
 ~bMoveList ()
 
bMoveListoperator= (bMoveList const &ml)
 
 bMoveList (bMoveList const &ml)=delete
 
 bMoveList (bMoveList &&ml)=delete
 
bMoveListoperator= (bMoveList &&ml)=delete
 
movenum_t adjustQSMoves ()
 reduce the number of QS moves to filter out the best ones only
 
bool atLeastOneMovePossible (bBasicBoard &b)
 see if at least one move can be played e.g.
 
movenum_t generateMoves (bBasicBoard const &b)
 generate moves if not yet generated
 
void emptyMoveList ()
 
constexpr movenum_t getNumberOfMoves () const
 
constexpr movenum_t getNumberOfQSMoves () const
 
bMove const & operator[] (movenum_t const moveid) const
 
constexpr fromto_t getFromTo (movenum_t const moveid) const
 
constexpr bmove_t getBMoveT (movenum_t const moveid) const
 
movenum_t addWhiteMoveIfValid (bBasicBoard const &b, bMove &m)
 Only add move to movelist if valid.
 
movenum_t addBlackMoveIfValid (bBasicBoard const &b, bMove &m)
 Only add move to movelist if valid.
 
movenum_t addWhitePromotionIfValid (bBasicBoard const &b, bMove &m)
 Only add move to movelist if valid.
 
movenum_t addBlackPromotionIfValid (bBasicBoard const &b, bMove &m)
 Only add move to movelist if valid.
 
void sortMoves (bool const bFastSort)
 sort moves and update bestmove id if less than 5 moves, sort all if more than 5 moves, and less than 3 qs moves, sort 3 best if more than 5 moves and at least 3 qs moves, sort qsmoves + 1
 
void clearScores ()
 
void clearScores (bScore const sc)
 
bool setScoreOfMove (movenum_t const moveid, bScore const score)
 Store score of move and update best move.
 
bool setMinScoreOfMove (movenum_t const moveid, bScore const score)
 Store score of move and update best move (minimum)
 
void setScoreOfMoveUnsorted (movenum_t const moveid, bScore const score)
 Store score of move and update best move.
 
void setMinScoreOfMoveUnsorted (movenum_t const moveid, bScore const score)
 Store score of move and update best move.
 
constexpr bScore getBestMoveScore () const
 
void setBestMoveScore (bScore const score)
 
void setBestMoveScore (movenum_t const moveid, bScore const score)
 
void setMoveScore (movenum_t const moveid, bScore const score)
 
constexpr movenum_t getBestMoveId () const
 
void setBestMoveId (movenum_t const n)
 
void clearBestMoveId ()
 
void setNeedSorted ()
 
void clearNeedSorted ()
 
void setKeepScores ()
 
void clearKeepScores ()
 

Public Attributes

movenum_t curmoveid = 0
 

Protected Member Functions

constexpr bool isGenerated () const
 
void setIsGenerated ()
 
void clearIsGenerated ()
 
constexpr bool isSorted () const
 
constexpr bool isNotSorted () const
 
void setIsSorted ()
 
void clearIsSorted ()
 
constexpr bool isOnlyMove () const
 
void setIsOnlyMove ()
 
void clearIsOnlyMove ()
 
constexpr bool isPossibleMove () const
 
void setIsPossibleMove ()
 
void clearIsPossibleMove ()
 
constexpr bool isNeedSorted () const
 
constexpr bool isNoNeedSorted () const
 
constexpr bool isKeepScores () const
 
constexpr bool isNoKeepScores () const
 

Friends

std::ostream & operator<< (std::ostream &os, bMoveList const &ml)
 

Detailed Description

Definition at line 15 of file movelist.h.

Constructor & Destructor Documentation

◆ bMoveList() [1/4]

bMoveList::bMoveList ( )
inlineexplicit

Definition at line 17 of file movelist.h.

Referenced by bMoveList(), bMoveList(), bMoveList(), operator<<, operator=(), and operator=().

+ Here is the caller graph for this function:

◆ bMoveList() [2/4]

bMoveList::bMoveList ( bMoveList & ml)
inline

Definition at line 20 of file movelist.h.

+ Here is the call graph for this function:

◆ ~bMoveList()

bMoveList::~bMoveList ( )
inline

Definition at line 27 of file movelist.h.

◆ bMoveList() [3/4]

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

◆ bMoveList() [4/4]

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

Member Function Documentation

◆ operator=() [1/2]

bMoveList & bMoveList::operator= ( bMoveList const & ml)
inline

Definition at line 30 of file movelist.h.

+ Here is the call graph for this function:

◆ operator=() [2/2]

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

◆ adjustQSMoves()

movenum_t bMoveList::adjustQSMoves ( )

reduce the number of QS moves to filter out the best ones only

Definition at line 460 of file movelist.cpp.

+ Here is the call graph for this function:

◆ atLeastOneMovePossible()

bool bMoveList::atLeastOneMovePossible ( bBasicBoard & b)

see if at least one move can be played e.g.

(stale-)mate eval called from addMoveToList, iterative search main loop and gameEndedResult

Definition at line 481 of file movelist.cpp.

Referenced by bPositionEvaluation::gameEndedResult(), and bSearchAlgorithm::SearchBestMove().

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

◆ generateMoves()

movenum_t bMoveList::generateMoves ( bBasicBoard const & b)

generate moves if not yet generated

Parameters
bboard to generate moves
Returns
number of moves generated

Definition at line 417 of file movelist.cpp.

Referenced by bPgnMove::bPgnMove(), bPgnMoveList::bPgnMoveList(), SearchAlphaBeta::CalcBestMove(), SearchMiniMax::CalcBestMove(), SearchRandom::CalcBestMove(), bel_debug::execute(), bGame::playPGNMoves(), and SearchAlphaBeta::Quiescence().

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

◆ emptyMoveList()

void bMoveList::emptyMoveList ( )

Definition at line 447 of file movelist.cpp.

Referenced by SearchRandom::CalcBestMove().

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

◆ getNumberOfMoves()

movenum_t bMoveList::getNumberOfMoves ( ) const
inlineconstexpr

Definition at line 49 of file movelist.h.

Referenced by bPgnMove::bPgnMove(), SearchEvalPosOnly::CalcBestMove(), generateMoves(), and operator<<.

+ Here is the caller graph for this function:

◆ getNumberOfQSMoves()

movenum_t bMoveList::getNumberOfQSMoves ( ) const
inlineconstexpr

Definition at line 51 of file movelist.h.

Referenced by operator<<, and SearchAlphaBeta::Quiescence().

+ Here is the caller graph for this function:

◆ operator[]()

bMove const & bMoveList::operator[] ( movenum_t const moveid) const
inline

Definition at line 54 of file movelist.h.

◆ getFromTo()

fromto_t bMoveList::getFromTo ( movenum_t const moveid) const
inlineconstexpr

Definition at line 56 of file movelist.h.

◆ getBMoveT()

bmove_t bMoveList::getBMoveT ( movenum_t const moveid) const
inlineconstexpr

Definition at line 58 of file movelist.h.

Referenced by bPgnMoveList::bPgnMoveList().

+ Here is the caller graph for this function:

◆ addWhiteMoveIfValid()

movenum_t bMoveList::addWhiteMoveIfValid ( bBasicBoard const & b,
bMove & m )

Only add move to movelist if valid.

Parameters
bboard on which move is calculated
mmove to be added
Returns
number of moves added (1), meaning player is not in check after move

Definition at line 251 of file movelist.cpp.

Referenced by bWhitePawn::addCapturePawnMove(), bWhitePawn::addEPMove(), bWhitePiece::addMove(), bWhitePiece::addMoves(), bWhitePawn::addNonCapturePawnMove(), and bWhiteKing::GenerateMoves().

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

◆ addBlackMoveIfValid()

movenum_t bMoveList::addBlackMoveIfValid ( bBasicBoard const & b,
bMove & m )

Only add move to movelist if valid.

Parameters
bboard on which move is calculated
mmove to be added
Returns
number of moves added (1), meaning player is not in check after move

Definition at line 267 of file movelist.cpp.

Referenced by bBlackPawn::addCapturePawnMove(), bBlackPawn::addEPMove(), bBlackPiece::addMove(), bBlackPiece::addMoves(), bBlackPawn::addNonCapturePawnMove(), and bBlackKing::GenerateMoves().

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

◆ addWhitePromotionIfValid()

movenum_t bMoveList::addWhitePromotionIfValid ( bBasicBoard const & b,
bMove & m )

Only add move to movelist if valid.

Parameters
bboard on which move is calculated
mmove to be added
Returns
number of moves added (4), meaning, player is not in check after move
Todo
optimize in case of uncover check just by moving pawn

Definition at line 283 of file movelist.cpp.

Referenced by bWhitePawn::addCapturePromotionMove(), and bWhitePawn::addNonCapturePromotionMove().

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

◆ addBlackPromotionIfValid()

movenum_t bMoveList::addBlackPromotionIfValid ( bBasicBoard const & b,
bMove & m )

Only add move to movelist if valid.

Parameters
bboard on which move is calculated
mmove to be added
Returns
number of moves added (4), meaning, player is not in check after move
Todo
optimize in case of uncover check just by moving pawn

Definition at line 324 of file movelist.cpp.

Referenced by bBlackPawn::addCapturePromotionMove(), and bBlackPawn::addNonCapturePromotionMove().

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

◆ sortMoves()

void bMoveList::sortMoves ( bool const bFastSort)

sort moves and update bestmove id if less than 5 moves, sort all if more than 5 moves, and less than 3 qs moves, sort 3 best if more than 5 moves and at least 3 qs moves, sort qsmoves + 1

Parameters
bFastSortonly do partial sorting (default)
Todo
allow for sorting the other way around and putting lowest score first

Definition at line 369 of file movelist.cpp.

Referenced by SearchAlphaBeta::CalcBestMove(), SearchBruteForce::CalcBestMove(), bel_debug::execute(), and SearchAlphaBeta::Quiescence().

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

◆ clearScores() [1/2]

void bMoveList::clearScores ( )
inline

◆ clearScores() [2/2]

void bMoveList::clearScores ( bScore const sc)
inline

Definition at line 69 of file movelist.h.

◆ setScoreOfMove()

bool bMoveList::setScoreOfMove ( movenum_t const moveid,
bScore const score )

Store score of move and update best move.

Parameters
moveidof move to be stored [1 -> max number of moves]
scoreto be stored
Returns
true if best score updated

Definition at line 157 of file movelist.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:

◆ setMinScoreOfMove()

bool bMoveList::setMinScoreOfMove ( movenum_t const moveid,
bScore const score )

Store score of move and update best move (minimum)

Parameters
moveidof move to be stored [1 -> max number of moves]
scoreto be stored
Returns
true if best score updated

Definition at line 184 of file movelist.cpp.

+ Here is the call graph for this function:

◆ setScoreOfMoveUnsorted()

void bMoveList::setScoreOfMoveUnsorted ( movenum_t const moveid,
bScore const score )

Store score of move and update best move.

Parameters
moveidof move to be stored [1 -> max number of moves]
scoreto be stored

Definition at line 210 of file movelist.cpp.

Referenced by SearchMiniMax::CalcBestMove(), and SearchRandom::CalcBestMove().

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

◆ setMinScoreOfMoveUnsorted()

void bMoveList::setMinScoreOfMoveUnsorted ( movenum_t const moveid,
bScore const score )

Store score of move and update best move.

Parameters
moveidof move to be stored [1 -> max number of moves]
scoreto be stored

Definition at line 230 of file movelist.cpp.

Referenced by SearchMiniMax::CalcBestMove().

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

◆ getBestMoveScore()

bScore bMoveList::getBestMoveScore ( ) const
inlineconstexpr

Definition at line 78 of file movelist.h.

Referenced by SearchMiniMax::CalcBestMove().

+ Here is the caller graph for this function:

◆ setBestMoveScore() [1/2]

void bMoveList::setBestMoveScore ( bScore const score)
inline

Definition at line 80 of file movelist.h.

Referenced by SearchMiniMax::CalcBestMove(), SearchAlphaBeta::Quiescence(), setMinScoreOfMove(), setMinScoreOfMoveUnsorted(), setScoreOfMove(), and setScoreOfMoveUnsorted().

+ Here is the caller graph for this function:

◆ setBestMoveScore() [2/2]

void bMoveList::setBestMoveScore ( movenum_t const moveid,
bScore const score )
inline

Definition at line 82 of file movelist.h.

+ Here is the call graph for this function:

◆ setMoveScore()

void bMoveList::setMoveScore ( movenum_t const moveid,
bScore const score )
inline

Definition at line 84 of file movelist.h.

Referenced by setBestMoveScore(), setMinScoreOfMove(), setMinScoreOfMoveUnsorted(), setScoreOfMove(), and setScoreOfMoveUnsorted().

+ Here is the caller graph for this function:

◆ getBestMoveId()

movenum_t bMoveList::getBestMoveId ( ) const
inlineconstexpr

◆ setBestMoveId()

void bMoveList::setBestMoveId ( movenum_t const n)
inline

Definition at line 89 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ clearBestMoveId()

void bMoveList::clearBestMoveId ( )
inline

Definition at line 91 of file movelist.h.

Referenced by emptyMoveList(), and sortMoves().

+ Here is the caller graph for this function:

◆ setNeedSorted()

void bMoveList::setNeedSorted ( )
inline

Definition at line 94 of file movelist.h.

Referenced by SearchBruteForce::CalcBestMove().

+ Here is the caller graph for this function:

◆ clearNeedSorted()

void bMoveList::clearNeedSorted ( )
inline

Definition at line 96 of file movelist.h.

Referenced by SearchMiniMax::CalcBestMove(), and SearchRandom::CalcBestMove().

+ Here is the caller graph for this function:

◆ setKeepScores()

void bMoveList::setKeepScores ( )
inline

Definition at line 98 of file movelist.h.

Referenced by SearchMiniMax::CalcBestMove().

+ Here is the caller graph for this function:

◆ clearKeepScores()

void bMoveList::clearKeepScores ( )
inline

Definition at line 100 of file movelist.h.

Referenced by SearchMiniMax::CalcBestMove(), and SearchRandom::CalcBestMove().

+ Here is the caller graph for this function:

◆ isGenerated()

bool bMoveList::isGenerated ( ) const
inlineconstexprprotected

Definition at line 107 of file movelist.h.

Referenced by generateMoves().

+ Here is the caller graph for this function:

◆ setIsGenerated()

void bMoveList::setIsGenerated ( )
inlineprotected

Definition at line 109 of file movelist.h.

Referenced by generateMoves().

+ Here is the caller graph for this function:

◆ clearIsGenerated()

void bMoveList::clearIsGenerated ( )
inlineprotected

Definition at line 111 of file movelist.h.

Referenced by emptyMoveList().

+ Here is the caller graph for this function:

◆ isSorted()

bool bMoveList::isSorted ( ) const
inlineconstexprprotected

Definition at line 113 of file movelist.h.

Referenced by adjustQSMoves().

+ Here is the caller graph for this function:

◆ isNotSorted()

bool bMoveList::isNotSorted ( ) const
inlineconstexprprotected

Definition at line 115 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ setIsSorted()

void bMoveList::setIsSorted ( )
inlineprotected

Definition at line 117 of file movelist.h.

Referenced by emptyMoveList(), setMinScoreOfMove(), setScoreOfMove(), and sortMoves().

+ Here is the caller graph for this function:

◆ clearIsSorted()

void bMoveList::clearIsSorted ( )
inlineprotected

Definition at line 119 of file movelist.h.

Referenced by setMinScoreOfMove(), and setScoreOfMove().

+ Here is the caller graph for this function:

◆ isOnlyMove()

bool bMoveList::isOnlyMove ( ) const
inlineconstexprprotected

Definition at line 123 of file movelist.h.

◆ setIsOnlyMove()

void bMoveList::setIsOnlyMove ( )
inlineprotected

Definition at line 125 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ clearIsOnlyMove()

void bMoveList::clearIsOnlyMove ( )
inlineprotected

Definition at line 127 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ isPossibleMove()

bool bMoveList::isPossibleMove ( ) const
inlineconstexprprotected

Definition at line 131 of file movelist.h.

Referenced by atLeastOneMovePossible().

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

◆ setIsPossibleMove()

void bMoveList::setIsPossibleMove ( )
inlineprotected

Definition at line 133 of file movelist.h.

Referenced by atLeastOneMovePossible(), and generateMoves().

+ Here is the caller graph for this function:

◆ clearIsPossibleMove()

void bMoveList::clearIsPossibleMove ( )
inlineprotected

Definition at line 135 of file movelist.h.

Referenced by emptyMoveList().

+ Here is the caller graph for this function:

◆ isNeedSorted()

bool bMoveList::isNeedSorted ( ) const
inlineconstexprprotected

Definition at line 138 of file movelist.h.

Referenced by setScoreOfMove(), and sortMoves().

+ Here is the caller graph for this function:

◆ isNoNeedSorted()

bool bMoveList::isNoNeedSorted ( ) const
inlineconstexprprotected

Definition at line 140 of file movelist.h.

◆ isKeepScores()

bool bMoveList::isKeepScores ( ) const
inlineconstexprprotected

Definition at line 142 of file movelist.h.

◆ isNoKeepScores()

bool bMoveList::isNoKeepScores ( ) const
inlineconstexprprotected

Definition at line 144 of file movelist.h.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
bMoveList const & ml )
friend

Definition at line 512 of file movelist.cpp.

Member Data Documentation

◆ curmoveid