mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Simplify away SEE verification
After 4 simplificatons over PR#4453 the idea does not yield significant improvement anymore. Maybe also https://tests.stockfishchess.org/tests/view/640c88092644b62c3394c1c5 was a fluke. Passed non-regression bounds: STC: https://tests.stockfishchess.org/tests/view/64705389c079b6583146d873 LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 131936 W: 35040 L: 34930 D: 61966 Ptnml(0-2): 336, 14559, 36035, 14735, 303 LTC: https://tests.stockfishchess.org/tests/view/6471a2ade549d9cf2fb213cd LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 407700 W: 109999 L: 110164 D: 187537 Ptnml(0-2): 279, 39913, 123689, 39632, 337 closes https://github.com/official-stockfish/Stockfish/pull/4595 bench: 2675974
This commit is contained in:
parent
6cf8d938c5
commit
5930c0defb
3 changed files with 8 additions and 30 deletions
|
@ -1061,7 +1061,7 @@ Key Position::key_after(Move m) const {
|
||||||
/// SEE value of move is greater or equal to the given threshold. We'll use an
|
/// SEE value of move is greater or equal to the given threshold. We'll use an
|
||||||
/// algorithm similar to alpha-beta pruning with a null window.
|
/// algorithm similar to alpha-beta pruning with a null window.
|
||||||
|
|
||||||
bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
|
bool Position::see_ge(Move m, Value threshold) const {
|
||||||
|
|
||||||
assert(is_ok(m));
|
assert(is_ok(m));
|
||||||
|
|
||||||
|
@ -1080,7 +1080,7 @@ bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
assert(color_of(piece_on(from)) == sideToMove);
|
assert(color_of(piece_on(from)) == sideToMove);
|
||||||
occupied = pieces() ^ from ^ to; // xoring to is important for pinned piece logic
|
Bitboard occupied = pieces() ^ from ^ to; // xoring to is important for pinned piece logic
|
||||||
Color stm = sideToMove;
|
Color stm = sideToMove;
|
||||||
Bitboard attackers = attackers_to(to, occupied);
|
Bitboard attackers = attackers_to(to, occupied);
|
||||||
Bitboard stmAttackers, bb;
|
Bitboard stmAttackers, bb;
|
||||||
|
@ -1111,43 +1111,43 @@ bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
|
||||||
// the bitboard 'attackers' any X-ray attackers behind it.
|
// the bitboard 'attackers' any X-ray attackers behind it.
|
||||||
if ((bb = stmAttackers & pieces(PAWN)))
|
if ((bb = stmAttackers & pieces(PAWN)))
|
||||||
{
|
{
|
||||||
occupied ^= least_significant_square_bb(bb);
|
|
||||||
if ((swap = PawnValueMg - swap) < res)
|
if ((swap = PawnValueMg - swap) < res)
|
||||||
break;
|
break;
|
||||||
|
occupied ^= least_significant_square_bb(bb);
|
||||||
|
|
||||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((bb = stmAttackers & pieces(KNIGHT)))
|
else if ((bb = stmAttackers & pieces(KNIGHT)))
|
||||||
{
|
{
|
||||||
occupied ^= least_significant_square_bb(bb);
|
|
||||||
if ((swap = KnightValueMg - swap) < res)
|
if ((swap = KnightValueMg - swap) < res)
|
||||||
break;
|
break;
|
||||||
|
occupied ^= least_significant_square_bb(bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((bb = stmAttackers & pieces(BISHOP)))
|
else if ((bb = stmAttackers & pieces(BISHOP)))
|
||||||
{
|
{
|
||||||
occupied ^= least_significant_square_bb(bb);
|
|
||||||
if ((swap = BishopValueMg - swap) < res)
|
if ((swap = BishopValueMg - swap) < res)
|
||||||
break;
|
break;
|
||||||
|
occupied ^= least_significant_square_bb(bb);
|
||||||
|
|
||||||
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
attackers |= attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((bb = stmAttackers & pieces(ROOK)))
|
else if ((bb = stmAttackers & pieces(ROOK)))
|
||||||
{
|
{
|
||||||
occupied ^= least_significant_square_bb(bb);
|
|
||||||
if ((swap = RookValueMg - swap) < res)
|
if ((swap = RookValueMg - swap) < res)
|
||||||
break;
|
break;
|
||||||
|
occupied ^= least_significant_square_bb(bb);
|
||||||
|
|
||||||
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
|
attackers |= attacks_bb<ROOK>(to, occupied) & pieces(ROOK, QUEEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((bb = stmAttackers & pieces(QUEEN)))
|
else if ((bb = stmAttackers & pieces(QUEEN)))
|
||||||
{
|
{
|
||||||
occupied ^= least_significant_square_bb(bb);
|
|
||||||
if ((swap = QueenValueMg - swap) < res)
|
if ((swap = QueenValueMg - swap) < res)
|
||||||
break;
|
break;
|
||||||
|
occupied ^= least_significant_square_bb(bb);
|
||||||
|
|
||||||
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
|
attackers |= (attacks_bb<BISHOP>(to, occupied) & pieces(BISHOP, QUEEN))
|
||||||
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
|
| (attacks_bb<ROOK >(to, occupied) & pieces(ROOK , QUEEN));
|
||||||
|
@ -1162,11 +1162,6 @@ bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const {
|
||||||
return bool(res);
|
return bool(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Position::see_ge(Move m, Value threshold) const {
|
|
||||||
Bitboard occupied;
|
|
||||||
return see_ge(m, occupied, threshold);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Position::is_draw() tests whether the position is drawn by 50-move rule
|
/// Position::is_draw() tests whether the position is drawn by 50-move rule
|
||||||
/// or by repetition. It does not detect stalemates.
|
/// or by repetition. It does not detect stalemates.
|
||||||
|
|
|
@ -143,7 +143,6 @@ public:
|
||||||
void undo_null_move();
|
void undo_null_move();
|
||||||
|
|
||||||
// Static Exchange Evaluation
|
// Static Exchange Evaluation
|
||||||
bool see_ge(Move m, Bitboard& occupied, Value threshold = VALUE_ZERO) const;
|
|
||||||
bool see_ge(Move m, Value threshold = VALUE_ZERO) const;
|
bool see_ge(Move m, Value threshold = VALUE_ZERO) const;
|
||||||
|
|
||||||
// Accessing hash keys
|
// Accessing hash keys
|
||||||
|
|
|
@ -989,26 +989,10 @@ moves_loop: // When in check, search starts here
|
||||||
+ captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] / 7 < alpha)
|
+ captureHistory[movedPiece][to_sq(move)][type_of(pos.piece_on(to_sq(move)))] / 7 < alpha)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Bitboard occupied;
|
|
||||||
// SEE based pruning (~11 Elo)
|
// SEE based pruning (~11 Elo)
|
||||||
if (!pos.see_ge(move, occupied, Value(-212) * depth))
|
if (!pos.see_ge(move, Value(-205) * depth))
|
||||||
{
|
|
||||||
// Don't prune the move if opponent King/Queen/Rook gets a discovered attack during or after the exchanges
|
|
||||||
Bitboard leftEnemies = pos.pieces(~us, KING, QUEEN, ROOK);
|
|
||||||
Bitboard attacks = 0;
|
|
||||||
occupied |= to_sq(move);
|
|
||||||
while (leftEnemies && !attacks)
|
|
||||||
{
|
|
||||||
Square sq = pop_lsb(leftEnemies);
|
|
||||||
attacks = pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
|
|
||||||
// Exclude Queen/Rook(s) which were already threatened before SEE (opponent King can't be in check when it's our turn)
|
|
||||||
if (attacks && sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us)))
|
|
||||||
attacks = 0;
|
|
||||||
}
|
|
||||||
if (!attacks)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int history = (*contHist[0])[movedPiece][to_sq(move)]
|
int history = (*contHist[0])[movedPiece][to_sq(move)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue