aboutsummaryrefslogtreecommitdiff
path: root/include/negamax.c
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/negamax.c
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/negamax.c')
-rw-r--r--include/negamax.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/negamax.c b/include/negamax.c
index 6c29481..c86eeab 100644
--- a/include/negamax.c
+++ b/include/negamax.c
@@ -100,6 +100,7 @@ float negamax_generate(tak_state_p state) {
// this is constant across iterative deepening
const uint64_t root_hash = zobrist_compute(state);
+ state->hash = root_hash; // anchor the incremental hash at the root
#ifdef RECORD_PV
pv_leaf_t iteration_leaf;
#endif
@@ -197,7 +198,7 @@ static float negamax(tak_state_p state, const uint8_t cur_depth,
action_take(state, actions[idx]);
- const uint64_t child_hash = zobrist_compute(state);
+ const uint64_t child_hash = state->hash;
// Compute the value of the node and retain the leaf that produced it.
float node_value;