summaryrefslogtreecommitdiff
path: root/board.h
blob: f21403b2716d926370401c4ec6db64a3c0ea775c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <cstdint>


enum win_t {
	WIN_NONE,
	WIN_P0,
	WIN_P1,
	WIN_DRAW,
};

struct Board {
	// as bit array: [16 * y + 4 * x + z]
	// (x,y) = floor position, z = height with z=0 on the bottom
	uint64_t bd[2];

	static Board empty();
	static Board uninitialised();

	void drop(int xy, int v);
	bool stkFull(int xy) const;
	win_t checkWin() const;
	uint64_t hash() const;
	int numFilled() const;
	bool isEmpty() const;
	int numValidMoves() const;
	int playerToMove() const;

	bool operator==(const Board &other) const;

protected:
	Board() = default;
};