diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-20 21:14:44 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-20 21:14:44 +0530 |
| commit | 1ebaab7b771c4c73be66895515f948ffe2394cc0 (patch) | |
| tree | 47ae3d951056cc9a3e3b4aa76f0b15fd631a16b0 /include/engine/ttable.h | |
| parent | a0970bddbd9f6b97b6a12ba7f73fd1810a2e1e1b (diff) | |
simple ttable tests
Diffstat (limited to 'include/engine/ttable.h')
| -rw-r--r-- | include/engine/ttable.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/include/engine/ttable.h b/include/engine/ttable.h index 2ee1a5c..8b1938a 100644 --- a/include/engine/ttable.h +++ b/include/engine/ttable.h @@ -1,11 +1,13 @@ #ifndef TTABLE_H #define TTABLE_H +#include "engine/moves.h" #include "bitboard.h" +#include <stdatomic.h> #define TABLE_BITS 24 #define TABLE_SIZE (1ULL << TABLE_BITS) -#define MASK (TABLE_SIZE - 1) +#define TT_MASK (TABLE_SIZE - 1) #define TT_BUCKET_SIZE 4 static struct zobrist_keys { @@ -15,6 +17,9 @@ static struct zobrist_keys { u64 en_passant[64]; } zobrist_keys; +void zobrist_init(); +u64 zobrist_hash(position_t position); + enum { TT_EXACT, TT_LOWERBOUND, TT_UPPERBOUND }; typedef struct { atomic_uint_fast64_t key; @@ -28,16 +33,29 @@ typedef struct { typedef struct { tentry_t entries[TT_BUCKET_SIZE]; + int items_filled; } tbucket_t; typedef tbucket_t* ttable_t; -void ttable_init(); -u64 zobrist_hash(position_t position); -void ttable_store( - ttable_t *ttable, u64 key, move_t move, i16 score, - i16 eval, u16 depth, u16 generation, u8 flag -); -tentry_t *ttable_probe(ttable_t *table, u64 key); +struct ttable_insert_args { + u64 key; + move_t move; + i16 score; + i16 eval; + u16 depth; + u16 generation; + u8 flag; +}; + +void ttable_init(ttable_t *table); +void ttable_deinit(ttable_t table); +void __ttable_insert(ttable_t table, struct ttable_insert_args args); +tentry_t *ttable_find(ttable_t table, u64 key); + +#define ttable_insert(ttable, ...) __ttable_insert( \ + ttable, \ + (struct ttable_insert_args) { __VA_ARGS__ } \ +) #endif // TTABLE_H |
