X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=72ab9a1228d36bc58deb8d40e0c92c45fb896f87;hp=be6e360af337c5b4e527b99c67a58fc40ee8d659;hb=67d91dfd505ce7e2c641c12e5d14b50896874ec7;hpb=ef0496ff4095330eaea4b33bb14e0386942fd093 diff --git a/src/search.cpp b/src/search.cpp index be6e360a..72ab9a12 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -51,6 +51,11 @@ using std::endl; using Eval::evaluate; using namespace Search; +// For some reason argument-dependent lookup (ADL) doesn't work for Android's +// STLPort, so explicitly qualify following functions. +using std::count; +using std::find; + namespace { // Set to true to force running with one thread. Used for debugging @@ -67,7 +72,7 @@ namespace { const Depth RazorDepth = 4 * ONE_PLY; // Dynamic razoring margin based on depth - inline Value razor_margin(Depth d) { return Value(0x200 + 0x10 * int(d)); } + inline Value razor_margin(Depth d) { return Value(512 + 16 * int(d)); } // Maximum depth for use of dynamic threat detection when null move fails low const Depth ThreatDepth = 5 * ONE_PLY; @@ -77,13 +82,13 @@ namespace { // At Non-PV nodes we do an internal iterative deepening search // when the static evaluation is bigger then beta - IIDMargin. - const Value IIDMargin = Value(0x100); + const Value IIDMargin = Value(256); // Minimum depth for use of singular extension const Depth SingularExtensionDepth[] = { 8 * ONE_PLY, 6 * ONE_PLY }; // Futility margin for quiescence search - const Value FutilityMarginQS = Value(0x80); + const Value FutilityMarginQS = Value(128); // Futility lookup tables (initialized at startup) and their access functions Value FutilityMargins[16][64]; // [depth][moveNumber] @@ -178,7 +183,7 @@ namespace { // Test for a capture that triggers a pawn endgame if ( captureOrPromotion && type_of(pos.piece_on(to_sq(m))) != PAWN - && !is_special(m) + && type_of(m) == NORMAL && ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) - PieceValueMidgame[pos.piece_on(to_sq(m))] == VALUE_ZERO)) return true; @@ -224,7 +229,7 @@ int64_t Search::perft(Position& pos, Depth depth) { StateInfo st; int64_t cnt = 0; - MoveList ml(pos); + MoveList ml(pos); // At the last ply just return the number of moves (leaf nodes) if (depth == ONE_PLY) @@ -656,7 +661,7 @@ namespace { && (ss-1)->eval != VALUE_NONE && ss->eval != VALUE_NONE && !pos.captured_piece_type() - && !is_special(move)) + && type_of(move) == NORMAL) { Square to = to_sq(move); H.update_gain(pos.piece_on(to), to, -(ss-1)->eval - ss->eval); @@ -703,16 +708,16 @@ namespace { ss->currentMove = MOVE_NULL; // Null move dynamic reduction based on depth - int R = 3 + (depth >= 5 * ONE_PLY ? depth / 8 : 0); + Depth R = 3 * ONE_PLY + depth / 4; // Null move dynamic reduction based on value if (refinedValue - PawnValueMidgame > beta) - R++; + R += ONE_PLY; pos.do_null_move(st); (ss+1)->skipNullMove = true; - nullValue = depth-R*ONE_PLY < ONE_PLY ? -qsearch(pos, ss+1, -beta, -alpha, DEPTH_ZERO) - : - search(pos, ss+1, -beta, -alpha, depth-R*ONE_PLY); + nullValue = depth-R < ONE_PLY ? -qsearch(pos, ss+1, -beta, -alpha, DEPTH_ZERO) + : - search(pos, ss+1, -beta, -alpha, depth-R); (ss+1)->skipNullMove = false; pos.do_null_move(st); @@ -727,7 +732,7 @@ namespace { // Do verification search at high depths ss->skipNullMove = true; - Value v = search(pos, ss, alpha, beta, depth-R*ONE_PLY); + Value v = search(pos, ss, alpha, beta, depth-R); ss->skipNullMove = false; if (v >= beta) @@ -897,7 +902,7 @@ split_point_start: // At split points actual search starts from here && !inCheck && !dangerous && move != ttMove - && !is_castle(move) + && type_of(move) != CASTLE && (bestValue > VALUE_MATED_IN_MAX_PLY || bestValue == -VALUE_INFINITE)) { // Move count based pruning @@ -956,7 +961,7 @@ split_point_start: // At split points actual search starts from here && !isPvMove && !captureOrPromotion && !dangerous - && !is_castle(move) + && type_of(move) != CASTLE && ss->killers[0] != move && ss->killers[1] != move) { @@ -1052,7 +1057,6 @@ split_point_start: // At split points actual search starts from here // Step 19. Check for split if ( !SpNode && depth >= Threads.min_split_depth() - && depth - reduction(depth, moveCount) >= Threads.min_split_depth() && bestValue < beta && Threads.available_slave_exists(thisThread) && !Signals.stop @@ -1222,12 +1226,12 @@ split_point_start: // At split points actual search starts from here && !givesCheck && move != ttMove && enoughMaterial - && !is_promotion(move) + && type_of(move) != PROMOTION && !pos.is_passed_pawn_push(move)) { futilityValue = futilityBase + PieceValueEndgame[pos.piece_on(to_sq(move))] - + (is_enpassant(move) ? PawnValueEndgame : VALUE_ZERO); + + (type_of(move) == ENPASSANT ? PawnValueEndgame : VALUE_ZERO); if (futilityValue < beta) { @@ -1255,7 +1259,7 @@ split_point_start: // At split points actual search starts from here if ( !PvNode && (!inCheck || evasionPrunable) && move != ttMove - && !is_promotion(move) + && type_of(move) != PROMOTION && pos.see_sign(move) < 0) continue;