summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-08-31 17:04:27 +0300
committereug-vs <eugene@eug-vs.xyz>2022-08-31 17:04:27 +0300
commitbc42b0b1746bc316c8e63b42c64bcf17a1ac011f (patch)
treebced043725e1e989c22f09525e034486a907862e
parentd6f49b139b42b9e6ff4fdaba3427972a4c07dd93 (diff)
downloadc-chess-bc42b0b1746bc316c8e63b42c64bcf17a1ac011f.tar.gz
feat: display transposition table cardinality
-rw-r--r--src/main.c4
1 files changed, 4 insertions, 0 deletions
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);