Open
Conversation
Track which quiet moves (from_square → to_square) cause beta cutoffs across the search tree using a 64×64 history table. Quiet moves with higher history scores are searched first, dramatically improving alpha-beta cutoff rates. On beta cutoff of a quiet move, the history score is incremented by depth² (deeper cutoffs are weighted more heavily). Benchmark at depth 4: - Nodes: 4,760,507 → 3,124,410 (−34.4%) - NPS: 22,634 → 24,696 (+9.1%) - Total time: 210.32s → 126.51s (−39.8%) Some positions show enormous reductions, e.g., Position 46: 986,591 → 20,495 nodes (−97.9%).
BenchmarksThe following benchmarks are available for this PR:
Post a comment with the command to trigger a benchmark run. |
Greptile SummaryImplements history heuristic for quiet move ordering using a 64×64 table indexed by Key changes:
Architecture:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| moonfish/engines/alpha_beta.py | Added history heuristic with 64×64 table tracking quiet moves causing beta cutoffs, properly threaded through negamax recursion |
| moonfish/move_ordering.py | Updated organize_moves() to sort quiet moves by history score when provided, maintains backward compatibility |
Flowchart
flowchart TD
A[search_move: Initialize history table 64×64] --> B[Call negamax with history]
B --> C{Depth > 0?}
C -->|No| D[Quiescence search]
C -->|Yes| E[organize_moves with history]
E --> F[Sort: captures first, then quiet moves by history score]
F --> G[Loop through moves]
G --> H[Recursive negamax with history]
H --> I{Score >= beta?}
I -->|Yes - Beta cutoff| J{Is quiet move?}
J -->|Yes| K[history from_sq to_sq += depth²]
J -->|No - Capture| L[Skip history update]
K --> M[Return beta cutoff]
L --> M
I -->|No| N[Update alpha, continue loop]
N --> G
D --> O[Return evaluation]
M --> O
Last reviewed commit: b85883e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Track which quiet moves (from_square → to_square) cause beta cutoffs across the search tree using a 64×64 history table. Quiet moves with higher history scores are searched first, dramatically improving alpha-beta cutoff rates.
depth²(deeper cutoffs weighted more)organize_moves()accepts optionalhistoryparameter; without it, behavior is unchangedBenchmark results (depth 4)
Notable per-position improvements:
Local Stockfish Benchmark
Settings: 20 games, Stockfish skill 3, 10s/move, no opening book.
Use
/run-stockfish-benchmarkfor CI validation with opening book and longer time control.Test plan
/run-nps-benchmark/run-stockfish-benchmark