summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-09-08 12:50:01 +0300
committereug-vs <eugene@eug-vs.xyz>2022-09-08 12:50:01 +0300
commitdaf0a82f1e45a182be05eef5a2fcc4b24d61bcca (patch)
treea80507d1e9e7a41723090c30547d8b27614eeed6
parentc0ffcf118ca558c066b2ff6b15d2c3b3742d0cf8 (diff)
downloadc-chess-daf0a82f1e45a182be05eef5a2fcc4b24d61bcca.tar.gz
feat: redo search if out of aspiration window
-rw-r--r--src/main.c14
1 files changed, 10 insertions, 4 deletions
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);