-
Notifications
You must be signed in to change notification settings - Fork 4
Improve quiescence search #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
82526b0 to
5f456a9
Compare
e8b9ff6 to
df8a32b
Compare
5f456a9 to
edb7941
Compare
df8a32b to
bfb11c1
Compare
845a25a to
72e2bf9
Compare
Enhances quiescence search with better draw detection and check handling: - Add draw detection: fifty-move rule, insufficient material, repetition - Proper check handling: when in check, search all evasions instead of only tactical moves (position is unstable, can't use stand-pat) - Add is_tactical_move() helper for cleaner move filtering - Update organize_moves_quiescence() to use tactical move detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72e2bf9 to
7bcc2f0
Compare
…search-improvements
🔬 Stockfish Benchmark Resultsvs Stockfish Skill Level 3
Non-checkmate endings:
vs Stockfish Skill Level 4
Non-checkmate endings:
vs Stockfish Skill Level 5
Non-checkmate endings:
Configuration
|
Greptile OverviewGreptile SummaryThis PR significantly improves the quiescence search implementation by adding draw detection (fifty-move rule, insufficient material, threefold repetition), properly handling check positions by searching all evasions instead of just captures, and refactoring tactical move detection into a cleaner Key improvements:
The changes align well with standard quiescence search algorithms and should improve tactical accuracy. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| moonfish/engines/alpha_beta.py | Improved quiescence search with draw detection, proper check handling, and best_score tracking |
| moonfish/move_ordering.py | Added is_tactical_move() helper for cleaner tactical move detection (captures, promotions, checks) |
Sequence Diagram
sequenceDiagram
participant QS as quiescence_search
participant Board
participant MO as organize_moves_quiescence
QS->>Board: is_check()
alt In Check
Board-->>QS: true
QS->>QS: Set best_score = -inf
QS->>Board: Get all legal moves (evasions)
else Not In Check
Board-->>QS: false
QS->>Board: eval_board() → stand_pat
alt stand_pat >= beta
QS-->>QS: Return beta (cutoff)
end
QS->>QS: Set best_score = stand_pat
QS->>QS: Update alpha = max(alpha, stand_pat)
QS->>MO: organize_moves_quiescence()
MO->>MO: Filter tactical moves (captures, promotions, checks)
MO-->>QS: tactical_moves
end
loop For each move
QS->>Board: push(move)
QS->>Board: is_repetition(2)?
alt Repetition Draw
Board-->>QS: true
QS->>QS: score = 0
else Not Repetition
Board-->>QS: false
QS->>QS: Recursive quiescence_search()
QS-->>QS: score = -recursive_result
end
QS->>Board: pop()
alt score > best_score
QS->>QS: Update best_score
end
alt score >= beta
QS-->>QS: Return beta (cutoff)
end
QS->>QS: Update alpha = max(alpha, score)
end
QS-->>QS: Return best_score
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 1 comment
moonfish/engines/alpha_beta.py
Outdated
|
|
||
| # Check if this move leads to a repetition (draw) | ||
| if board.is_repetition(2): | ||
| score: float = 0 # Draw score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary type annotation on variable assignment
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: moonfish/engines/alpha_beta.py
Line: 143:143
Comment:
unnecessary type annotation on variable assignment
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
🔬 Stockfish Benchmark Resultsvs Stockfish Skill Level 3
Non-checkmate endings:
vs Stockfish Skill Level 4
Non-checkmate endings:
vs Stockfish Skill Level 5
Non-checkmate endings:
Configuration
|
Summary
is_tactical_move()helper for cleaner tactical move detectionDetails
Draw Detection
The quiescence search now detects draws:
board.is_fifty_moves()board.is_insufficient_material()board.is_repetition(2)after each moveCheck Handling
When in check, the position is unstable and we can't use stand-pat for pruning:
Tactical Move Detection
New
is_tactical_move()function that identifies:Previously used
is_zeroing()which included quiet pawn pushes.Test plan
🤖 Generated with Claude Code