aboutsummaryrefslogtreecommitdiff
path: root/include/tak.h
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2026-09-08 11:55:28 +0100
committertslil <tslil@posteo.de>2026-09-09 21:45:17 +0100
commit1c9e266ae25f7f6067806d139e5971ce8513d2f6 (patch)
tree9b935954310a56ee7fdba07db5f03888fc5af7b0 /include/tak.h
parent7ef68374e8a58684b299b0f46f7ed850d5a87190 (diff)
~25% speedup in selfplay due to: incremental zobrist hashing, smarter road checking, re-using the input computed for the NN
Diffstat (limited to 'include/tak.h')
-rw-r--r--include/tak.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/tak.h b/include/tak.h
index d60c221..324c41f 100644
--- a/include/tak.h
+++ b/include/tak.h
@@ -55,6 +55,9 @@ typedef struct tak_state_s {
enum WIN_TYPE won;
enum COLOUR current_colour;
uint8_t white_count, black_count, ply, board_size;
+ // incremental zobrist hash; maintained by action_take/action_undo and
+ // re-anchored at the search root (see zobrist.h)
+ uint64_t hash;
} *tak_state_p;
#define NUM_SHIFT 4
@@ -63,6 +66,8 @@ typedef struct tak_state_s {
#define STONE_MASK 3 // 0b00000011
#define STONE_AT(state, l) (state->celldat[(l)] & STONE_MASK)
#define COUNT_AT(state, l) (state->celldat[(l)] >> NUM_SHIFT)
+// the colour stack holds one bit per stone, the top stone in the LSB
+#define TOP_COLOUR_AT(state, l) (state->colours[(l)] & 1)
#define THE_COORDS(board_size, col, row) ((col) + (row)*board_size)
// ===================================================================