Skip to content

Optimizing quiescence search#123

Open
Hardcode3 wants to merge 2 commits intomainfrom
quiescence_optimization
Open

Optimizing quiescence search#123
Hardcode3 wants to merge 2 commits intomainfrom
quiescence_optimization

Conversation

@Hardcode3
Copy link
Copy Markdown
Owner

@Hardcode3 Hardcode3 commented Apr 24, 2026

📌 Optimizing quiescence search

📄 Description

  • Splitted legal moves generation into two, adding a legal capture moves generation. This new legal capture moves generation avoids creating all legal moves and then filtering for capture, hence resulting in a non-negligible speedup (see Additional Notes). Quiescence search now use legal capture moves generation and negamax search uses legal moves generation.

🧩 Type of Change

🚀 Performance improvement

📝 Additional Notes

Benchmark setup

A quick benchmark was run on the Kiwipete position.

Hardware used: M4 MacBook Pro with 16 Gb Unified Memory.

d
     a   b   c   d   e   f   g   h  
   +---+---+---+---+---+---+---+---+
 8 | r |   |   |   | k |   |   | r | 8
   +---+---+---+---+---+---+---+---+
 7 | p |   | p | p | q | p | b |   | 7
   +---+---+---+---+---+---+---+---+
 6 | b | n |   |   | p | n | p |   | 6
   +---+---+---+---+---+---+---+---+
 5 |   |   |   | P | N |   |   |   | 5
   +---+---+---+---+---+---+---+---+
 4 |   | p |   |   | P |   |   |   | 4
   +---+---+---+---+---+---+---+---+
 3 |   |   | N |   |   | Q |   | p | 3
   +---+---+---+---+---+---+---+---+
 2 | P | P | P | B | B | P | P | P | 2
   +---+---+---+---+---+---+---+---+
 1 | R |   |   |   | K |   |   | R | 1
   +---+---+---+---+---+---+---+---+
     a   b   c   d   e   f   g   h  

FEN notation: r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w - - 0 1
Zobrist hash: 7132688269263558591

Benchmark results

Experiment (depth 1) Total nodes Negamax nodes Quiescence nodes Total time (s) Nodes per second
Before 34'038'939 47 34'038'892 12.0681 2'820'582
After 34'038'939 47 34'038'892 8.07602 4'214'818
Result = = = -3.99208 + 1'394'236
Experiment (depth 2) Total nodes Negamax nodes Quiescence nodes Total time (s) Nodes per second
Before 80'460'423 610 80'459'813 28.2208 2'851'100
After 80'460'423 610 80'459'813 18.656 4'312'841
Result = = = -9.5648 + 1'461'741

Still, most of the nodes explored here are from the quiescence search. This number could be drastically reduced using for instance Static Exchange Evaluation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant