From 1c9e266ae25f7f6067806d139e5971ce8513d2f6 Mon Sep 17 00:00:00 2001 From: tslil Date: Tue, 8 Sep 2026 11:55:28 +0100 Subject: ~25% speedup in selfplay due to: incremental zobrist hashing, smarter road checking, re-using the input computed for the NN --- include/tak.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/tak.h') 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) // =================================================================== -- cgit v1.3.1