Skip to content

[4/6] Add iterative deepening with aspiration windows and TT move ordering#36

Open
luccabb wants to merge 1 commit intofeature/mvv-lva-killer-movesfrom
feature/iterative-deepening-aspiration
Open

[4/6] Add iterative deepening with aspiration windows and TT move ordering#36
luccabb wants to merge 1 commit intofeature/mvv-lva-killer-movesfrom
feature/iterative-deepening-aspiration

Conversation

@luccabb
Copy link
Owner

@luccabb luccabb commented Jan 20, 2026

Summary

  • Implement iterative deepening (search depth 1, 2, 3, ... N)
  • Add aspiration windows for faster searches
  • Add TT move ordering (best move from previous search tried first)

Details

Iterative Deepening

Instead of searching directly to depth N, we search depth 1, then 2, then 3, etc:

for depth in range(1, target_depth + 1):
    score, move = negamax(board, depth, ...)

Benefits:

  • TT entries from depth N-1 improve move ordering at depth N
  • Enables future time management (stop when time runs out)
  • Killer moves accumulate across iterations

Aspiration Windows

After the first iteration, we use a narrow window around the previous score:

  • Initial window: ±50 centipawns
  • If search fails high/low, double the window and re-search
  • Fall back to full window if window exceeds ±500 cp

This reduces the number of nodes searched when the score is stable.

TT Move Ordering

  • Extract best move from TT lookup even if score can't be used
  • Put TT move first in the move list before all other moves
  • TT move is the best move found at a shallower depth, excellent for ordering

Test plan

  • All 64 unit tests pass
  • Verified iterative deepening visits all depths

🤖 Generated with Claude Code

@luccabb luccabb force-pushed the feature/mvv-lva-killer-moves branch from 0b53062 to 944a0e0 Compare January 21, 2026 06:40
@luccabb luccabb force-pushed the feature/iterative-deepening-aspiration branch from f205ab8 to cda6ab5 Compare January 21, 2026 06:41
@luccabb luccabb force-pushed the feature/mvv-lva-killer-moves branch from 944a0e0 to f1001bf Compare January 21, 2026 06:44
@luccabb luccabb force-pushed the feature/iterative-deepening-aspiration branch from cda6ab5 to 0a7dc0c Compare January 21, 2026 06:44
@luccabb luccabb changed the title [6/9] Add iterative deepening with aspiration windows and TT move ordering [4/7] Add iterative deepening with aspiration windows and TT move ordering Jan 21, 2026
@luccabb luccabb force-pushed the feature/mvv-lva-killer-moves branch from f1001bf to 98ee9e1 Compare January 21, 2026 07:33
@luccabb luccabb force-pushed the feature/iterative-deepening-aspiration branch from 0a7dc0c to 134def0 Compare January 21, 2026 07:33
@luccabb luccabb changed the title [4/7] Add iterative deepening with aspiration windows and TT move ordering [4/6] Add iterative deepening with aspiration windows and TT move ordering Jan 21, 2026
@github-actions
Copy link

🔬 Stockfish Benchmark Results

vs Stockfish Skill Level 3

Metric Wins Losses Draws Total Win %
Overall 6 94 0 100 6.0%
As White 3 47 0 50 6.0%
As Black 3 47 0 50 6.0%

vs Stockfish Skill Level 4

Metric Wins Losses Draws Total Win %
Overall 2 97 1 100 2.0%
As White 2 47 1 50 4.0%
As Black 0 50 0 50 0%

Non-checkmate endings:

  • Draw by 3-fold repetition: 1

vs Stockfish Skill Level 5

Metric Wins Losses Draws Total Win %
Overall 0 98 2 100 0%
As White 0 49 1 50 0%
As Black 0 49 1 50 0%

Non-checkmate endings:

  • Draw by 3-fold repetition: 2
Configuration
  • 5 chunks × 20 rounds × 3 skill levels = 300 total games
  • Each opening played with colors reversed (-repeat) for fairness
  • Moonfish: 60s per move
  • Stockfish: 60+5 time control

…ering

Implements iterative deepening for better move ordering and future time management:

**Iterative Deepening:**
- Search depth 1, then 2, then 3, ... up to target depth
- Cache persists across all iterations (TT entries reused)
- Killer moves persist across iterations
- Best move from depth N-1 is tried first at depth N (via TT)

**Aspiration Windows:**
- After depth 1, use narrow window (±50 centipawns) around previous score
- If search fails outside window, re-search with doubled window
- Falls back to full window after 500cp expansion
- Reduces nodes searched when score is stable

**TT Move Ordering:**
- Save best move from TT lookup even if score can't be used
- Put TT move first in move list before searching
- Significantly improves move ordering at all depths

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@luccabb luccabb force-pushed the feature/mvv-lva-killer-moves branch from 8bab1bf to e73ebd6 Compare February 16, 2026 06:34
@luccabb luccabb force-pushed the feature/iterative-deepening-aspiration branch from 3f314f6 to 6e50edb Compare February 16, 2026 06:34
@luccabb
Copy link
Owner Author

luccabb commented Feb 16, 2026

/run-nps-benchmark

@github-actions
Copy link

⚡ NPS Benchmark Results

Metric Value
Depth 5
Positions 48
Total nodes 23349570
Total time 1902.64s
Nodes/second 12272

Node count is the primary signal — it's deterministic and catches search behavior changes. If the node count changes, the PR changed search behavior. NPS is informational only (CI runner performance varies).

Per-position breakdown
Position  1/48: nodes=21031      time=1.20s  nps=17502
Position  2/48: nodes=1129860    time=95.64s  nps=11813
Position  3/48: nodes=11903      time=0.65s  nps=18180
Position  4/48: nodes=263861     time=24.22s  nps=10896
Position  5/48: nodes=100749     time=11.54s  nps=8731
Position  6/48: nodes=146608     time=14.18s  nps=10342
Position  7/48: nodes=177580     time=20.56s  nps=8638
Position  8/48: nodes=171084     time=13.55s  nps=12627
Position  9/48: nodes=656782     time=58.41s  nps=11243
Position 10/48: nodes=220167     time=20.03s  nps=10990
Position 11/48: nodes=788160     time=82.85s  nps=9513
Position 12/48: nodes=513731     time=58.67s  nps=8756
Position 13/48: nodes=233763     time=22.63s  nps=10328
Position 14/48: nodes=256929     time=23.64s  nps=10866
Position 15/48: nodes=228144     time=20.25s  nps=11268
Position 16/48: nodes=177053     time=15.38s  nps=11515
Position 17/48: nodes=4593       time=0.28s  nps=16438
Position 18/48: nodes=5341       time=0.26s  nps=20867
Position 19/48: nodes=9642       time=0.63s  nps=15313
Position 20/48: nodes=39555      time=2.43s  nps=16307
Position 21/48: nodes=16248      time=1.09s  nps=14962
Position 22/48: nodes=943        time=0.05s  nps=18459
Position 23/48: nodes=2134       time=0.10s  nps=21611
Position 24/48: nodes=5916       time=0.37s  nps=16132
Position 25/48: nodes=5872       time=0.35s  nps=16559
Position 26/48: nodes=19219      time=1.26s  nps=15282
Position 27/48: nodes=85076      time=6.02s  nps=14128
Position 28/48: nodes=221090     time=18.17s  nps=12170
Position 29/48: nodes=14935      time=1.18s  nps=12672
Position 30/48: nodes=2550       time=0.16s  nps=16115
Position 31/48: nodes=278667     time=23.44s  nps=11889
Position 32/48: nodes=1360147    time=119.25s  nps=11405
Position 33/48: nodes=340668     time=40.60s  nps=8390
Position 34/48: nodes=968806     time=112.84s  nps=8585
Position 35/48: nodes=639806     time=45.48s  nps=14067
Position 36/48: nodes=5977156    time=459.53s  nps=13007
Position 37/48: nodes=8016673    time=568.66s  nps=14097
Position 38/48: nodes=2274       time=0.09s  nps=24671
Position 39/48: nodes=3075       time=0.14s  nps=22137
Position 40/48: nodes=15477      time=0.27s  nps=57476
Position 41/48: nodes=13944      time=0.75s  nps=18542
Position 42/48: nodes=12910      time=0.86s  nps=15041
Position 43/48: nodes=4247       time=0.19s  nps=21932
Position 44/48: nodes=35870      time=2.67s  nps=13453
Position 45/48: nodes=46602      time=3.61s  nps=12894
Position 46/48: nodes=102729     time=8.54s  nps=12031
Position 47/48: nodes=0          time=0.00s  nps=0  (terminal)
Position 48/48: nodes=0          time=0.00s  nps=0  (terminal)

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