Skip to content

Conversation

@luccabb
Copy link
Owner

@luccabb luccabb commented Jan 20, 2026

Summary

  • Add Late Move Reductions (LMR) to reduce search depth for late quiet moves
  • Add Principal Variation Search (PVS) for faster searches with good move ordering

Details

Late Move Reductions (LMR)

Reduce search depth for moves that are unlikely to be the best:

Conditions:

  • Depth >= 3 (need sufficient depth to reduce)
  • Move index >= 3 (first few moves get full depth)
  • Not in check (check positions are critical)
  • Quiet move (no capture, no check, no promotion)

Implementation:

reduction = 1  # Reduce by 1 ply
board_score = negamax(depth - 1 - reduction, ...)
if board_score > alpha:
    board_score = negamax(depth - 1, ...)  # Re-search at full depth

Principal Variation Search (PVS)

Optimize search based on the assumption that the first move is best:

Implementation:

  • First move: full alpha-beta window search
  • Later moves: zero window search first (faster)
  • If zero window beats alpha, re-search with full window
if move_index == 0:
    score = negamax(alpha=-beta, beta=-alpha)  # Full window
else:
    score = negamax(alpha=-alpha-1, beta=-alpha)  # Zero window
    if score > alpha:
        score = negamax(alpha=-beta, beta=-alpha)  # Re-search

Test plan

  • All 64 unit tests pass
  • Verified LMR only applies to late quiet moves
  • Verified PVS re-searches when needed

🤖 Generated with Claude Code

@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/iterative-deepening-aspiration branch from cda6ab5 to 0a7dc0c Compare January 21, 2026 06:44
@luccabb luccabb changed the title [7/9] Add Late Move Reductions (LMR) and Principal Variation Search (PVS) [5/7] Add Late Move Reductions (LMR) and Principal Variation Search (PVS) Jan 21, 2026
@luccabb luccabb force-pushed the feature/iterative-deepening-aspiration branch from 0a7dc0c to 134def0 Compare January 21, 2026 07:33
…PVS)

Implements two key search optimizations:

**Late Move Reductions (LMR):**
- Reduce search depth for late quiet moves (move_index >= 3)
- Only apply when: depth >= 3, not in check, move is quiet
- Quiet moves = no capture, no check, no promotion
- Simple reduction of 1 ply (more aggressive formulas tested but hurt accuracy)
- Re-search at full depth if reduced search finds promising score

**Principal Variation Search (PVS):**
- First move: search with full alpha-beta window
- Later moves: search with zero window (alpha, alpha+1)
- If zero window search beats alpha, re-search with full window
- Saves time when first move is best (which is often true with good ordering)

Both techniques work together:
- PVS assumes first move is best (good with TT/killer/MVV-LVA ordering)
- LMR reduces work on moves unlikely to be best
- Combined, they significantly reduce nodes searched

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@luccabb luccabb changed the title [5/7] Add Late Move Reductions (LMR) and Principal Variation Search (PVS) [5/6] Add Late Move Reductions (LMR) and Principal Variation Search (PVS) Jan 21, 2026
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.

2 participants