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

#include <movelist.h>

Public Member Functions

 bMoveList ()
 
 ~bMoveList ()
 
 bMoveList (bMoveList const &ml)=delete
 
 bMoveList (bMoveList &&ml)=delete
 
bMoveListoperator= (bMoveList const &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 ()
 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 ()
 
bool setScoreOfMove (movenum_t const moveid, bScore const score)
 Store score of move and update best move.
 
void setScoreOfMoveUnsorted (movenum_t const moveid, bScore const score)
 Store score of move and update best move.
 
constexpr bScore getBestMoveScore () const
 
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 ()
 

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/3]

bMoveList::bMoveList ( )
inlineexplicit

Definition at line 17 of file movelist.h.

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

+ Here is the caller graph for this function:

◆ ~bMoveList()

bMoveList::~bMoveList ( )
inline

Definition at line 20 of file movelist.h.

◆ bMoveList() [2/3]

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

◆ bMoveList() [3/3]

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)
delete
+ 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 383 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 404 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

Returns
number of moves generated

Definition at line 340 of file movelist.cpp.

Referenced by bPgnMove::bPgnMove(), bPgnMoveList::bPgnMoveList(), SearchAlphaBeta::CalcBestMove(), SearchAlphaBetaFH::CalcBestMove(), SearchRandom::CalcBestMove(), bel_debug::execute(), bGame::playGameMove(), 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 370 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 34 of file movelist.h.

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

+ Here is the caller graph for this function:

◆ getNumberOfQSMoves()

movenum_t bMoveList::getNumberOfQSMoves ( ) const
inlineconstexpr

Definition at line 36 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 39 of file movelist.h.

◆ getFromTo()

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

Definition at line 41 of file movelist.h.

◆ getBMoveT()

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

Definition at line 43 of file movelist.h.

◆ 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 177 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 193 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 209 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 250 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 ( )

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

Definition at line 293 of file movelist.cpp.

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

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

◆ clearScores()

void bMoveList::clearScores ( )
inline

Definition at line 52 of file movelist.h.

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

+ Here is the caller graph for this function:

◆ 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 130 of file movelist.cpp.

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

+ Here is the call graph for this function:
+ Here is the caller 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 156 of file movelist.cpp.

Referenced by SearchRandom::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 59 of file movelist.h.

◆ setBestMoveScore()

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

Definition at line 61 of file movelist.h.

Referenced by SearchAlphaBeta::Quiescence(), setScoreOfMove(), and setScoreOfMoveUnsorted().

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

◆ setMoveScore()

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

Definition at line 63 of file movelist.h.

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

+ Here is the caller graph for this function:

◆ getBestMoveId()

movenum_t bMoveList::getBestMoveId ( ) const
inlineconstexpr

Definition at line 66 of file movelist.h.

Referenced by bGame::getEpdMoveInPosition(), isPossibleMove(), setScoreOfMove(), setScoreOfMoveUnsorted(), and bGame::WaitForSearchEnd().

+ Here is the caller graph for this function:

◆ setBestMoveId()

void bMoveList::setBestMoveId ( movenum_t const n)
inline

Definition at line 68 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ clearBestMoveId()

void bMoveList::clearBestMoveId ( )
inline

Definition at line 70 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 73 of file movelist.h.

◆ clearNeedSorted()

void bMoveList::clearNeedSorted ( )
inline

Definition at line 75 of file movelist.h.

Referenced by SearchRandom::CalcBestMove(), and bGame::playGameMove().

+ Here is the caller graph for this function:

◆ setKeepScores()

void bMoveList::setKeepScores ( )
inline

Definition at line 77 of file movelist.h.

◆ clearKeepScores()

void bMoveList::clearKeepScores ( )
inline

Definition at line 79 of file movelist.h.

Referenced by SearchRandom::CalcBestMove(), and bGame::playGameMove().

+ Here is the caller graph for this function:

◆ isGenerated()

bool bMoveList::isGenerated ( ) const
inlineconstexprprotected

Definition at line 83 of file movelist.h.

Referenced by generateMoves().

+ Here is the caller graph for this function:

◆ setIsGenerated()

void bMoveList::setIsGenerated ( )
inlineprotected

Definition at line 85 of file movelist.h.

Referenced by generateMoves().

+ Here is the caller graph for this function:

◆ clearIsGenerated()

void bMoveList::clearIsGenerated ( )
inlineprotected

Definition at line 87 of file movelist.h.

Referenced by emptyMoveList().

+ Here is the caller graph for this function:

◆ isSorted()

bool bMoveList::isSorted ( ) const
inlineconstexprprotected

Definition at line 89 of file movelist.h.

Referenced by adjustQSMoves().

+ Here is the caller graph for this function:

◆ isNotSorted()

bool bMoveList::isNotSorted ( ) const
inlineconstexprprotected

Definition at line 91 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ setIsSorted()

void bMoveList::setIsSorted ( )
inlineprotected

Definition at line 93 of file movelist.h.

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

+ Here is the caller graph for this function:

◆ clearIsSorted()

void bMoveList::clearIsSorted ( )
inlineprotected

Definition at line 95 of file movelist.h.

Referenced by setScoreOfMove().

+ Here is the caller graph for this function:

◆ isOnlyMove()

bool bMoveList::isOnlyMove ( ) const
inlineconstexprprotected

Definition at line 99 of file movelist.h.

◆ setIsOnlyMove()

void bMoveList::setIsOnlyMove ( )
inlineprotected

Definition at line 101 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ clearIsOnlyMove()

void bMoveList::clearIsOnlyMove ( )
inlineprotected

Definition at line 103 of file movelist.h.

Referenced by sortMoves().

+ Here is the caller graph for this function:

◆ isPossibleMove()

bool bMoveList::isPossibleMove ( ) const
inlineconstexprprotected

Definition at line 107 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 109 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 111 of file movelist.h.

Referenced by emptyMoveList().

+ Here is the caller graph for this function:

◆ isNeedSorted()

bool bMoveList::isNeedSorted ( ) const
inlineconstexprprotected

Definition at line 114 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 116 of file movelist.h.

◆ isKeepScores()

bool bMoveList::isKeepScores ( ) const
inlineconstexprprotected

Definition at line 118 of file movelist.h.

◆ isNoKeepScores()

bool bMoveList::isNoKeepScores ( ) const
inlineconstexprprotected

Definition at line 120 of file movelist.h.

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 435 of file movelist.cpp.