From daf0a82f1e45a182be05eef5a2fcc4b24d61bcca Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Sep 2022 12:50:01 +0300 Subject: feat: redo search if out of aspiration window --- src/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 1c5664a..ddc5a39 100644 --- a/src/main.c +++ b/src/main.c @@ -640,6 +640,7 @@ Move iterative_deepening(int* board, int color, long hash, Transposition* transp clock_t deadline = start + MOVE_TIME * CLOCKS_PER_SEC; int alpha = -INFINITY; int beta = +INFINITY; + int window_size = 4; while (depth <= MAX_DEPTH) { best_move = move; @@ -658,10 +659,15 @@ Move iterative_deepening(int* board, int color, long hash, Transposition* transp index_to_notation(move.destination, move_in_notation + 2); printf("Done (%s with evaluation %.2f) [%i positions analyzed]\n", move_in_notation, (double)move.value / 10, metrics); - alpha = move.value - 3; - beta = move.value + 3; - - depth++; + if (move.value < alpha || move.value > beta) { + printf("Out of aspiration window, re-doing the full search\n"); + alpha = -INFINITY; + beta = +INFINITY; + } else { + alpha = move.value - window_size; + beta = move.value + window_size; + depth++; + } } printf("Max depth (%i) reached in %.2f seconds\n", MAX_DEPTH, (double)(clock() - start) / CLOCKS_PER_SEC); -- cgit v1.2.3