BitBully 0.0.78
A fast, perfect-play Connect-4 engine in modern C++
Loading...
Searching...
No Matches
MoveList.h
Go to the documentation of this file.
1
5#ifndef MOVELIST_H
6#define MOVELIST_H
7#include <cstdint>
8
9// TODO: Definitions into cpp file
10namespace BitBully {
11
24class MoveList {
25 public:
27 // TODO: This is also defined in Board.h
28 using TBitBoard = uint64_t;
29
31 // TODO: This also:
32 static constexpr int N_COLUMNS = 7;
33
39 void insert(const TBitBoard move, const int score) {
40 int pos = size++;
41 for (; pos && m_arrayPrioQueue[pos - 1].score >= score; --pos)
42 m_arrayPrioQueue[pos] = m_arrayPrioQueue[pos - 1];
43 m_arrayPrioQueue[pos].move = move;
44 m_arrayPrioQueue[pos].score = score;
45 }
46
51 inline TBitBoard pop() {
52 return size ? m_arrayPrioQueue[--size].move : UINT64_C(0);
53 }
54
56 unsigned int getSize() const { return size; }
57
59 void reset() { size = 0; }
60
62 MoveList() : size{0}, m_arrayPrioQueue{} {}
63
64 private:
66 unsigned int size;
67
74 struct {
76 int score;
77 } m_arrayPrioQueue[N_COLUMNS];
78};
79} // namespace BitBully
80
81#endif // MOVELIST_H
void reset()
Empty the queue without freeing any memory.
Definition MoveList.h:59
TBitBoard move
Single-bit move mask.
Definition MoveList.h:75
unsigned int getSize() const
Number of moves currently stored.
Definition MoveList.h:56
MoveList()
Construct an empty move list.
Definition MoveList.h:62
TBitBoard pop()
Remove and return the highest-priority move.
Definition MoveList.h:51
void insert(const TBitBoard move, const int score)
Insert a (move, score) pair while keeping the queue sorted.
Definition MoveList.h:39
uint64_t TBitBoard
64-bit bitboard type (mirrors the alias defined in Board.h).
Definition MoveList.h:28
static constexpr int N_COLUMNS
Maximum number of moves the queue can hold.
Definition MoveList.h:32
int score
Priority score.
Definition MoveList.h:76
Top-level namespace for the BitBully Connect-4 engine.
Definition BitBully.h:26