Skip to content

Commit

Permalink
Do not prune useless checks in QS
Browse files Browse the repository at this point in the history
Passed both SPRT tests in "simplification mode", so with
elo0: -3.00 alpha: 0.05 elo1: 3.00 beta: 0.05

Short TC:
LLR: 2.96 (-2.94,2.94)
Total: 6243 W: 1302 L: 1195 D: 3746

Long TC
LLR: 2.96 (-2.94,2.94)
Total: 22972 W: 4124 L: 4020 D: 14828

bench: 4633330
  • Loading branch information
lucasart authored and mcostalba committed Sep 5, 2013
1 parent a30d357 commit 10b53e1
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ namespace {
void id_loop(Position& pos);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
bool check_is_dangerous(const Position& pos, Move move, Value futilityBase, Value beta);
bool allows(const Position& pos, Move first, Move second);
bool refutes(const Position& pos, Move first, Move second);
string uci_pv(const Position& pos, int depth, Value alpha, Value beta);
Expand Down Expand Up @@ -1267,16 +1266,6 @@ namespace {
&& pos.see_sign(move) < 0)
continue;

// Don't search useless checks
if ( !PvNode
&& !InCheck
&& givesCheck
&& move != ttMove
&& !pos.is_capture_or_promotion(move)
&& ss->staticEval + PawnValueMg / 4 < beta
&& !check_is_dangerous(pos, move, futilityBase, beta))
continue;

// Check for legality only before to do the move
if (!pos.pl_move_is_legal(move, ci.pinned))
continue;
Expand Down Expand Up @@ -1354,42 +1343,6 @@ namespace {
}


// check_is_dangerous() tests if a checking move can be pruned in qsearch()

bool check_is_dangerous(const Position& pos, Move move, Value futilityBase, Value beta)
{
Piece pc = pos.piece_moved(move);
Square from = from_sq(move);
Square to = to_sq(move);
Color them = ~pos.side_to_move();
Square ksq = pos.king_square(them);
Bitboard enemies = pos.pieces(them);
Bitboard kingAtt = pos.attacks_from<KING>(ksq);
Bitboard occ = pos.pieces() ^ from ^ ksq;
Bitboard oldAtt = pos.attacks_from(pc, from, occ);
Bitboard newAtt = pos.attacks_from(pc, to, occ);

// Checks which give opponent's king at most one escape square are dangerous
if (!more_than_one(kingAtt & ~(enemies | newAtt | to)))
return true;

// Queen contact check is very dangerous
if (type_of(pc) == QUEEN && (kingAtt & to))
return true;

// Creating new double threats with checks is dangerous
Bitboard b = (enemies ^ ksq) & newAtt & ~oldAtt;
while (b)
{
// Note that here we generate illegal "double move"!
if (futilityBase + PieceValue[EG][pos.piece_on(pop_lsb(&b))] >= beta)
return true;
}

return false;
}


// allows() tests whether the 'first' move at previous ply somehow makes the
// 'second' move possible, for instance if the moving piece is the same in
// both moves. Normally the second move is the threat (the best move returned
Expand Down

0 comments on commit 10b53e1

Please sign in to comment.