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:
rektdieandclaude committed 2026-11-15 14:52:58 +01:00
1 parent c45450255a
commit 695d2dd30d
3 files changed
+109 -25

No files matched your search

+5
View File
@@ -54,5 +54,10 @@ private:
};
void generate_legal(const Position& pos, MoveList& list);
// Legal captures (en passant included) and queen promotions, in the order
// generate_legal lists them.
void generate_noisy(const Position& pos, MoveList& list);
// Same as a non-empty generate_legal, but stops at the first move it finds.
bool has_legal_move(const Position& pos);
} // namespace rigby