summaryrefslogtreecommitdiff
path: root/board.h
diff options
context:
space:
mode:
Diffstat (limited to 'board.h')
-rw-r--r--board.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/board.h b/board.h
index f795d03..f21403b 100644
--- a/board.h
+++ b/board.h
@@ -1,16 +1,7 @@
#pragma once
-#include <stdbool.h>
-#include <stdint.h>
+#include <cstdint>
-typedef uint64_t u64;
-typedef uint8_t u8;
-
-
-// as bit array: [16 * y + 4 * x + z]
-// (x,y) = floor position, z = height with z=0 on the bottom
-typedef u64 board_t[2];
-typedef const u64 cboard_t[2];
enum win_t {
WIN_NONE,
@@ -19,7 +10,25 @@ enum win_t {
WIN_DRAW,
};
-void b_set(board_t B, cboard_t C);
-void b_drop(board_t B, int xy, int v);
-bool b_stk_full(cboard_t B, int xy);
-enum win_t b_win(cboard_t B);
+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;
+};