Skip to content

Conversation

@luccabb
Copy link
Owner

@luccabb luccabb commented Jan 20, 2026

Summary

  • Skip quiet moves at low depths when static evaluation is far below alpha
  • Margin-based pruning: depth 1 = 100cp, depth 2 = 200cp

Details

Futility Pruning

If the static evaluation plus a safety margin is still below alpha, quiet moves
are unlikely to improve the position enough to beat alpha. We skip them.

Implementation:

if depth <= 2 and not in_check:
    static_eval = self.eval_board(board)
    futility_margin = 100 * depth  # 100cp at depth 1, 200cp at depth 2
    can_futility_prune = static_eval + futility_margin < alpha

# In move loop:
if can_futility_prune and move_index > 0 and is_quiet_move:
    continue  # Skip this move

Safety Conditions

Pruning is conservative to avoid missing important moves:

  • Only at low depths (1-2 ply)
  • Never when in check
  • Never prune captures, checks, or promotions
  • Never prune the first move
  • Margin allows for reasonable positional improvement

Why it Works

At low depths near leaf nodes:

  • Quiet moves have limited potential to swing evaluation
  • If we're already losing by > margin, a quiet move won't save us
  • Captures/checks are still searched (tactical opportunities)

Test plan

  • All 64 unit tests pass
  • Verified pruning only happens for quiet moves at low depth

🤖 Generated with Claude Code

@luccabb luccabb force-pushed the feature/futility-pruning branch from 9f14f89 to 5019fdf Compare January 21, 2026 06:42
@luccabb luccabb force-pushed the feature/futility-pruning branch from 5019fdf to 369da0e Compare January 21, 2026 06:44
@luccabb luccabb changed the title [8/9] Add futility pruning [6/7] Add futility pruning Jan 21, 2026
Implements futility pruning to skip quiet moves that can't improve alpha:

**Futility Pruning:**
- At low depths (1-2), compute static evaluation
- If eval + margin < alpha, quiet moves can't help
- Skip quiet moves (no capture, check, or promotion)
- Never prune the first move (might be the only good one)

**Margin Calculation:**
- Depth 1: 100 centipawns margin
- Depth 2: 200 centipawns margin
- Larger margin at deeper depths allows for more potential improvement

**Conditions for pruning:**
- Depth <= 2
- Not in check (check positions are critical)
- Static eval + margin < alpha
- Move is quiet (not capture/check/promotion)
- Not the first move in the list

This is a forward pruning technique that can miss some moves, but
the marginsare conservative enough to rarely affect results while
significantly reducing nodes searched.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@luccabb luccabb force-pushed the feature/futility-pruning branch from 369da0e to fe21981 Compare January 21, 2026 07:33
@luccabb luccabb changed the title [6/7] Add futility pruning [6/6] Add futility pruning 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