diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-08-31 17:04:27 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-08-31 17:04:27 +0300 |
commit | bc42b0b1746bc316c8e63b42c64bcf17a1ac011f (patch) | |
tree | bced043725e1e989c22f09525e034486a907862e | |
parent | d6f49b139b42b9e6ff4fdaba3427972a4c07dd93 (diff) | |
download | c-chess-bc42b0b1746bc316c8e63b42c64bcf17a1ac011f.tar.gz |
feat: display transposition table cardinality
-rw-r--r-- | src/main.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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); |