From bc42b0b1746bc316c8e63b42c64bcf17a1ac011f Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 31 Aug 2022 17:04:27 +0300 Subject: feat: display transposition table cardinality --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 5107338..aa520b1 100644 --- a/src/main.c +++ b/src/main.c @@ -12,6 +12,8 @@ #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #define MIN(x, y) (((x) < (y)) ? (x) : (y)) +int TRANSPOSITION_TABLE_CARDINALITY = 0; + void generate_zobrist_seed(long* seed) { for (int i = 0; i < MAX_ZOBRIST_SEEDS; i++) { seed[i] = rand(); @@ -576,6 +578,7 @@ Move minimax_search(int* board, int color, int depth, int alpha, int beta, int* ? minimax_search(board, 1 - color, depth + 1, alpha, beta, metrics, hash, transposition_table, zobrist_seed).value : evaluate_position(board, available_moves_count, color); + if (!transposition_table[move_hash % TRANSPOSITION_TABLE_SIZE]) TRANSPOSITION_TABLE_CARDINALITY++; transposition_table[move_hash % TRANSPOSITION_TABLE_SIZE] = move.value; unmake_move(move, captured_piece, board); @@ -626,6 +629,7 @@ int main() { move = minimax_search(board, color, 0, -INFINITY, +INFINITY, &metrics, hash, transposition_table, zobrist_seed); end = clock(); printf("[%i positions analyzed in %f seconds]\n", metrics, (double)(end - start) / CLOCKS_PER_SEC); + printf("[Transposition table cardinality: %i]\n", TRANSPOSITION_TABLE_CARDINALITY); char move_in_notation[] = "xy XY"; index_to_notation(move.origin, move_in_notation); -- cgit v1.2.3