From eb74c23aced3fc5d76c3db26c1d5810e29ec6976 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 18 Aug 2022 10:35:45 +0300 Subject: feat: time minimax function --- src/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 5db2141..f517d06 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "config.h" #include "pieces.h" @@ -285,7 +286,7 @@ int compute_coverage(int* board, int color) { int compute_score(int* board) { int coverage_score = compute_coverage(board, WHITE) - compute_coverage(board, BLACK); - return compute_material_advantage(board, WHITE) + coverage_score; + return compute_material_advantage(board, WHITE) * 2 + coverage_score; } // Alpha-beta pruning @@ -370,12 +371,15 @@ int main() { input_move(move); } else { printf("Evaluating move for black...\n"); + clock_t start, end; int metrics = 0; + start = clock(); int value = find_best_move(move, board, color, 0, -INFINITY, +INFINITY, &metrics); + end = clock(); char move_in_notation[] = "xy XY"; index_to_notation(move[0], move_in_notation); index_to_notation(move[1], move_in_notation + 3); - printf("%i positions analyzed\n", metrics); + printf("[%i positions analyzed in %f seconds]\n", metrics, (double)(end - start) / CLOCKS_PER_SEC); printf("Best move for black is %s with score %i in #%i moves\n", move_in_notation, value, MAX_DEPTH); } -- cgit v1.2.3