commit 0f8fcd867fd7ddbae2c118b5639acc0c05e9a2af
parent 40ec0f1a8e50396cea47115cda5943fcaa6efbf5
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Sat, 5 Aug 2023 17:30:48 +0200
Null Move Pruning
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
Stellar
- VERSION 0.0.13
+ VERSION 0.0.14
DESCRIPTION "Chess engine written in C"
HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git
LANGUAGES C
diff --git a/src/engine/engine.c b/src/engine/engine.c
@@ -16,6 +16,7 @@
#define MAX_PLY 64
#define FULL_DEPTH 4
#define REDUCTION_LIMIT 3
+#define REDUCTION_MOVE 2
#define INFINITY 50000
#define WINDOW 50
@@ -151,6 +152,18 @@ int negamax(Stats *stats, const Board *board, int alpha, int beta, int depth) {
if (isCheck) depth++;
Board copy;
+
+ if (depth >= 3 && !isCheck && stats->ply) {
+ board_copy(board, ©);
+ board_side_switch(©);
+ board_enpassant_set(©, no_sq);
+
+ int score = -negamax(stats, ©, -beta, -beta + 2,
+ depth - 1 - REDUCTION_MOVE);
+
+ if (score >= beta) return beta;
+ }
+
MoveList list;
move_list_generate(&list, board);