aboutsummaryrefslogtreecommitdiff
path: root/include/tt.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2026-09-16 20:10:33 +0100
committertslil <tslil@posteo.de>2026-09-16 21:02:53 +0100
commit1898add0142b70b3fef5af78a6f3d7399a3f2cd5 (patch)
treeef62b4d6b6f78a426248f7636a83b77cce5edaa4 /include/tt.c
parent7f1566fb21dfe8c99bc770885cc2cc4e478e16b4 (diff)
fix tt issue for non-self-playHEADmain
A little subtle, but in non-self-play games sharing tt entries is incorrect. We must therefore key additionally on the evaulation function itself.
Diffstat (limited to 'include/tt.c')
-rw-r--r--include/tt.c12
1 files changed, 7 insertions, 5 deletions
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;