From 5cffc032da8402df79cf6cba4238b83ff5d29f7e Mon Sep 17 00:00:00 2001 From: ajithcj Date: Wed, 31 Aug 2016 05:51:52 +0000 Subject: [PATCH] Optimize order of a few conditions in search Also fix size of KingDanger array to reduce memory footprint. Small speed up of around 0.5% No functional change. --- src/evaluate.cpp | 2 +- src/search.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 177d2934..d533eed8 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -210,7 +210,7 @@ namespace { // in KingDanger[]. Various little "meta-bonuses" measuring the strength // of the enemy attack are added up into an integer, which is used as an // index to KingDanger[]. - Score KingDanger[512]; + Score KingDanger[400]; // KingAttackWeights[PieceType] contains king attack weights by piece type const int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 7, 5, 4, 1 }; diff --git a/src/search.cpp b/src/search.cpp index 9dfa5193..7fafe933 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -725,8 +725,8 @@ namespace { // Step 6. Razoring (skipped when in check) if ( !PvNode && depth < 4 * ONE_PLY - && eval + razor_margin[depth / ONE_PLY] <= alpha - && ttMove == MOVE_NONE) + && ttMove == MOVE_NONE + && eval + razor_margin[depth / ONE_PLY] <= alpha) { if ( depth <= ONE_PLY && eval + razor_margin[3 * ONE_PLY] <= alpha) @@ -924,8 +924,8 @@ moves_loop: // When in check search starts from here && !captureOrPromotion && !inCheck && !givesCheck - && !pos.advanced_pawn_push(move) - && bestValue > VALUE_MATED_IN_MAX_PLY) + && bestValue > VALUE_MATED_IN_MAX_PLY + && !pos.advanced_pawn_push(move)) { // Move count based pruning if (moveCountPruning) -- 2.39.2