From 1898add0142b70b3fef5af78a6f3d7399a3f2cd5 Mon Sep 17 00:00:00 2001 From: tslil Date: Wed, 16 Sep 2026 20:10:33 +0100 Subject: fix tt issue for non-self-play A little subtle, but in non-self-play games sharing tt entries is incorrect. We must therefore key additionally on the evaulation function itself. --- include/tt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include/tt.c') diff --git a/include/tt.c b/include/tt.c index 8ad6c56..c996791 100644 --- a/include/tt.c +++ b/include/tt.c @@ -36,20 +36,21 @@ int tt_init(void) { return EXIT_SUCCESS; } -tt_entry_t *tt_seek(const uint64_t key) { +tt_entry_t *tt_seek(const uint64_t key, const nn_function eval) { tt_entry_t *e = &table[key & TT_SIZE]; - if (e->gen == tt_gen && e->key == key) + if (e->gen == tt_gen && e->key == key && e->eval == eval) return e; return NULL; } -tt_entry_t *tt_store(const uint64_t key, const enum TT_FLAG flag, - const uint8_t depth, const float value, - const action_t action) { +tt_entry_t *tt_store(const uint64_t key, const nn_function eval, + const enum TT_FLAG flag, const uint8_t depth, + const float value, const action_t action) { tt_entry_t *e = &table[key & TT_SIZE]; if (e->gen == tt_gen && e->key == key) { // The slot holds this very position: update it (gen and key are already // correct). + e->eval = eval; e->flag = flag; e->value = value; e->depth = depth; @@ -61,6 +62,7 @@ tt_entry_t *tt_store(const uint64_t key, const enum TT_FLAG flag, if (e->gen == tt_gen && e->depth > depth) return NULL; e->key = key; + e->eval = eval; e->value = value; e->action = action; e->gen = tt_gen; -- cgit v1.3.1