BitBully 0.0.39
Loading...
Searching...
No Matches
MoveList.h
1#ifndef MOVELIST_H
2#define MOVELIST_H
3#include <cstdint>
4
5// TODO: Definitions into cpp file
6namespace BitBully {
7
8// A simple priority queue.
9class MoveList {
10 public:
11 // TODO: This is also defined in Board.h
12 using TBitBoard = uint64_t;
13
14 // TODO: This also:
15 static constexpr int N_COLUMNS = 7;
16
17 void insert(const TBitBoard move, const int score) {
18 int pos = size++;
19 for (; pos && m_arrayPrioQueue[pos - 1].score >= score; --pos)
20 m_arrayPrioQueue[pos] = m_arrayPrioQueue[pos - 1];
21 m_arrayPrioQueue[pos].move = move;
22 m_arrayPrioQueue[pos].score = score;
23 }
24
25 inline TBitBoard pop() {
26 return size ? m_arrayPrioQueue[--size].move : UINT64_C(0);
27 }
28
29 void reset() { size = 0; }
30
31 MoveList() : size{0}, m_arrayPrioQueue{} {}
32
33 private:
34 // number of stored moves
35 unsigned int size;
36
37 // An array-based priority queue containing a list of moves, where a higher
38 // score corresponds to a higher prio. In case two or more scores are equal,
39 // the FIFO principle holds
40 struct {
41 TBitBoard move;
42 int score;
43 } m_arrayPrioQueue[N_COLUMNS];
44};
45} // namespace BitBully
46
47#endif // MOVELIST_H