perf: generate only captures in quiescence
Out of check the quiescence search only searches captures and queen promotions, but every node generated all legal moves and threw the quiet ones away. It now generates just those (generate_noisy: the same legal generator with captures-only targets, no quiet pawn pushes, no castling), in the same order as the full generation, so search is unchanged. A node without any noisy move still has to tell stalemate from a quiet position; has_legal_move answers that and stops at the first legal move it finds. Playouts per second at 100k playouts, main -> this (two runs each): startpos 631k -> 725k +15% QGD middlegame 390k -> 446k +14% Kiwipete 106k -> 142k +34% Sicilian middle 334k -> 423k +27% rook endgame 851k -> 982k +15% Checked: perftsuite 7 passes. On 252,893 positions from random games (captures preferred, so they reach endgames, promotions and 400 positions without legal moves) generate_noisy equals generate_legal filtered to captures and queen promotions, in the same order, and has_legal_move equals a non-empty generate_legal. The bench is identical to main. Bench: 546966 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c45450255a
commit
695d2dd30d
3 files changed
+109
-25
No files matched your search
+11
-3
@@ -128,10 +128,18 @@ int quiescence(const Position& pos, int alpha, int beta, int ply) {
|
||||
alpha = std::max(alpha, stand_pat);
|
||||
}
|
||||
|
||||
// Out of check only captures and queen promotions are searched, so only
|
||||
// those are generated; a position without any of them is still checked
|
||||
// for stalemate.
|
||||
MoveList list;
|
||||
generate_legal(pos, list);
|
||||
if (list.empty()) return in_check ? -MATE + ply : 0;
|
||||
if (in_check && ply >= QS_MAX_PLY) return static_eval(pos);
|
||||
if (in_check) {
|
||||
generate_legal(pos, list);
|
||||
if (list.empty()) return -MATE + ply;
|
||||
if (ply >= QS_MAX_PLY) return static_eval(pos);
|
||||
} else {
|
||||
generate_noisy(pos, list);
|
||||
if (list.empty()) return has_legal_move(pos) ? best : 0;
|
||||
}
|
||||
|
||||
Move moves[256];
|
||||
int scores[256];
|
||||
|
||||
Reference in new issue
Block a user