X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=e53baabd98903430ae37bdc78d4bf64e3e4525bf;hb=43f84efa1552a82c87db7e791035e74bba6c6157;hp=5706b959f2d9ffeb1e0a121a001a7a44c31b5c3b;hpb=b1768c115cf2bbe7ed6f89dc53a8db85b4442353;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index 5706b959..e53baabd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -130,7 +130,7 @@ namespace { Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth); void id_loop(Position& pos); - bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bValue); + bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta); bool connected_moves(const Position& pos, Move m1, Move m2); Value value_to_tt(Value v, int ply); Value value_from_tt(Value v, int ply); @@ -1279,7 +1279,7 @@ split_point_start: // At split points actual search starts from here && move != ttMove && !pos.is_capture_or_promotion(move) && ss->eval + PawnValueMidgame / 4 < beta - && !check_is_dangerous(pos, move, futilityBase, beta, &bestValue)) + && !check_is_dangerous(pos, move, futilityBase, beta)) continue; // Check for legality only before to do the move @@ -1330,20 +1330,19 @@ split_point_start: // At split points actual search starts from here // bestValue is updated only when returning false because in that case move // will be pruned. - bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bestValue) + bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta) { Bitboard b, occ, oldAtt, newAtt, kingAtt; - Square from, to, ksq, victimSq; + Square from, to, ksq; Piece pc; Color them; - Value futilityValue, bv = *bestValue; from = from_sq(move); to = to_sq(move); them = ~pos.side_to_move(); ksq = pos.king_square(them); kingAtt = pos.attacks_from(ksq); - pc = pos.piece_on(from); + pc = pos.piece_moved(move); occ = pos.occupied_squares() & ~(1ULL << from) & ~(1ULL << ksq); oldAtt = pos.attacks_from(pc, from, occ); @@ -1361,23 +1360,13 @@ split_point_start: // At split points actual search starts from here // Rule 3. Creating new double threats with checks b = pos.pieces(them) & newAtt & ~oldAtt & ~(1ULL << ksq); - while (b) { - victimSq = pop_1st_bit(&b); - futilityValue = futilityBase + PieceValueEndgame[pos.piece_on(victimSq)]; - // Note that here we generate illegal "double move"! - if ( futilityValue >= beta - && pos.see_sign(make_move(from, victimSq)) >= 0) + if (futilityBase + PieceValueEndgame[pos.piece_on(pop_1st_bit(&b))] >= beta) return true; - - if (futilityValue > bv) - bv = futilityValue; } - // Update bestValue only if check is not dangerous (because we will prune the move) - *bestValue = bv; return false; } @@ -1767,14 +1756,14 @@ void RootMove::extract_pv_from_tt(Position& pos) { pos.do_move(m, *st++); while ( (tte = TT.probe(pos.key())) != NULL - && tte->move() != MOVE_NONE - && pos.is_pseudo_legal(tte->move()) - && pos.pl_move_is_legal(tte->move(), pos.pinned_pieces()) + && (m = tte->move()) != MOVE_NONE // Local copy, TT entry could change + && pos.is_pseudo_legal(m) + && pos.pl_move_is_legal(m, pos.pinned_pieces()) && ply < MAX_PLY && (!pos.is_draw() || ply < 2)) { - pv.push_back(tte->move()); - pos.do_move(tte->move(), *st++); + pv.push_back(m); + pos.do_move(m, *st++); ply++; } pv.push_back(MOVE_NONE); @@ -1865,7 +1854,7 @@ void Thread::idle_loop(SplitPoint* sp_master) { lock_grab(Threads.splitLock); assert(is_searching); - SplitPoint* sp = splitPoint; + SplitPoint* sp = curSplitPoint; lock_release(Threads.splitLock); @@ -1906,9 +1895,6 @@ void Thread::idle_loop(SplitPoint* sp_master) { Threads[master].wake_up(); } } - // In helpful master concept a master can help only a sub-tree of its split - // point, and because here is all finished is not possible master is booked. - assert(!is_searching); }