commit 1eb875775bfa42320616ff8b1e5ee913b1d8fac7
parent 25f5a5d8e5b1f22986782bfa72a779fc215dfefb
Author: benjamin paul <bpaul@bpaul.xyz>
Date: Sun, 8 Aug 2021 15:24:57 +1000
position struct
Diffstat:
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/board/bb.h b/src/board/bb.h
@@ -0,0 +1,4 @@
+#pragma once
+
+/* Bitboard */
+typedef unsigned long long bb;
diff --git a/src/board/pos.h b/src/board/pos.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "bb.h"
+
+enum sides { WHITE, BLACK, SIDE_CNT };
+
+enum pieces { PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, PIECE_CNT };
+
+struct pos {
+ bb sides[SIDE_CNT];
+ bb pieces[PIECE_CNT];
+
+ /* Only need one bit, either white or black */
+ char turn : 1;
+
+ /* Each bit represents one of the castling rules, a bit for whether white
+ * can kingside castle, one for queenside castling, and a bit for black for
+ * each too */
+ char castle : 4;
+
+ /* enpas refers to the square that a double pushed pawn moves to. Since
+ * there are 64 squares, 6 bits are needed */
+ char enpas : 6;
+
+ /* Tracker for 50 move rule */
+ unsigned char fifty;
+
+ /* Track game length (hence the name) */
+ unsigned short game_length;
+};