Belofte version 2.1.8
A promising chess program using the UCI or Winboard interface
movelist.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: movelist.h
3 * Project: part of belofte - A Promising Chess Program
4 * Author: yves
5 * SPDX-License-Identifier: GPL-2.0-only
6+----------------------------------------------------------------------*/
7
8#if !defined(MOVELIST_H)
9#define MOVELIST_H
10
11typedef std::vector<bMove> movelist_t;
12
13//-----------------------------------------------------------------------
14
15class bMoveList final {
16public:
17 bMoveList();
18 explicit bMoveList(bMoveList&&) noexcept;
19 explicit bMoveList(bBoard const& b);
20 ~bMoveList();
21
22 // no copy or move ctor nor assignment defined
23 bMoveList(bMoveList const&) = delete;
24 bMoveList& operator=(bMoveList const&) = delete;
25 bMoveList& operator=(bMoveList&&) = delete;
26
28 void emptyMoveList();
29 bool atLeastOneMovePossible(bBoard const& b) const;
30
33
34 bMove const& operator[](movenum_t const moveid) const;
35 basicmove_t getMoveT(movenum_t const moveid) const;
36
37 movenum_t addWhiteMoveIfValid(bBoard const& b, bMove const& m);
38 movenum_t addWhiteCaptureIfValid(bBoard const& b, case_t const& cf, case_t const& to);
39 movenum_t addBlackMoveIfValid(bBoard const& b, bMove const& m);
40 movenum_t addBlackCaptureIfValid(bBoard const& b, case_t const& cf, case_t const& to);
43
44 movenum_t setScoreOfMove(movenum_t const moveid, bScore const score);
45
47
48protected:
49 movelist_t m_lmoves; // = decltype(bMoveList::ml_moves){};
50
51private:
52 friend std::ostream& operator<<(std::ostream& os, bMoveList const& ml);
53
54private:
55 void addMoveAndSetScore(bBoard const& b, bMove const& m, bool const check);
56
57 bool m_isGenerated = false;
58 bool m_isSorted = false;
59 movenum_t m_nQSMoves = 0;
60 movenum_t m_bestmoveid = 0;
61};
62
63#endif // defined MOVELIST_H
64
65// eof
uint16_t basicmove_t
Definition belofte.h:107
uint_fast8_t movenum_t
Definition belofte.h:109
uint8_t case_t
Definition belofte.h:106
int16_t bScore
board
Definition board.h:147
Definition move.h:69
movenum_t addWhiteCaptureIfValid(bBoard const &b, case_t const &cf, case_t const &to)
Definition movelist.cpp:89
movenum_t addBlackPromotionIfValid(bBoard const &b, bMove const &m)
Only add move to movelist if valid.
Definition movelist.cpp:165
void emptyMoveList()
Definition movelist.cpp:284
movelist_t m_lmoves
Definition movelist.h:49
movenum_t setScoreOfMove(movenum_t const moveid, bScore const score)
Store score of move.
Definition movelist.cpp:207
movenum_t addWhitePromotionIfValid(bBoard const &b, bMove const &m)
Only add move to movelist if valid.
Definition movelist.cpp:125
movenum_t sortMoves()
Definition movelist.cpp:225
movenum_t addBlackCaptureIfValid(bBoard const &b, case_t const &cf, case_t const &to)
Definition movelist.cpp:112
movenum_t getNumberOfQSMoves() const
return number of non silent moves
Definition movelist.cpp:339
movenum_t getNumberOfMoves() const
Definition movelist.cpp:332
bMoveList(bMoveList &&) noexcept
movenum_t addBlackMoveIfValid(bBoard const &b, bMove const &m)
Only add move to movelist if valid.
Definition movelist.cpp:102
movenum_t addWhiteMoveIfValid(bBoard const &b, bMove const &m)
Only add move to movelist if valid.
Definition movelist.cpp:79
movenum_t generateMoves(bBoard const &b)
generate moves if not yet generated
Definition movelist.cpp:259
bool atLeastOneMovePossible(bBoard const &b) const
see if at least one move can be played e.g.
Definition movelist.cpp:296
basicmove_t getMoveT(movenum_t const moveid) const
Definition movelist.cpp:327
std::vector< bMove > movelist_t
Definition movelist.h:11