diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-08-18 10:35:45 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-08-18 10:35:45 +0300 |
commit | eb74c23aced3fc5d76c3db26c1d5810e29ec6976 (patch) | |
tree | 21172bdae2b6600493ab61b39cfbd826512ce482 | |
parent | 5cf1a520f190657cb0d5bb41c4dcc741795536ae (diff) | |
download | c-chess-eb74c23aced3fc5d76c3db26c1d5810e29ec6976.tar.gz |
feat: time minimax function
-rw-r--r-- | src/main.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,6 +1,7 @@ #include <locale.h> #include <stdio.h> #include <string.h> +#include <time.h> #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); } |