Enable null move pruning by default and fix parallel engine cleanup#51
Open
Enable null move pruning by default and fix parallel engine cleanup#51
Conversation
- Change default null_move from False to True in CLI. The bench already uses null_move=True, but UCI/Lichess games were playing without it, making the engine significantly weaker in actual play. - Fix resource leaks in all parallel engines (LazySMP, L1P, L2P) by using context managers (with statements) for Pool and Manager instead of bare constructors that never get cleaned up. - Add self.nodes = 0 reset in all parallel engine search_move methods. - Fix L1P score negation: negate opponent's scores and sort descending for clearer intent (functionally equivalent to the old ascending sort).
BenchmarksThe following benchmarks are available for this PR:
Post a comment with the command to trigger a benchmark run. |
Greptile SummaryEnables null move pruning by default in CLI to match benchmark configuration, fixing a significant weakness in UCI/Lichess games. Adds proper resource management to all parallel engines using context managers for Key changes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| moonfish/main.py | Changed --null-move CLI default from False to True, aligning UCI/Lichess play with benchmark configuration |
| moonfish/engines/lazy_smp.py | Added context managers for Pool/Manager to prevent resource leaks and added self.nodes = 0 reset |
| moonfish/engines/l1p_alpha_beta.py | Added context managers, self.nodes = 0 reset, fixed score negation and sort order for correct move selection |
| moonfish/engines/l2p_alpha_beta.py | Added context managers for Pool/Manager to prevent resource leaks and added self.nodes = 0 reset |
Flowchart
flowchart TD
A[search_move called] --> B[Reset self.nodes = 0]
B --> C[Create Pool and Manager<br/>with context managers]
C --> D{Engine Type?}
D -->|LazySMP| E[Run negamax N times<br/>in parallel on same board]
E --> F[All processes share<br/>transposition table cache]
F --> G[Return best move<br/>from shared cache]
D -->|Layer1Parallel| H[Generate all<br/>legal moves layer 1]
H --> I[Evaluate each move<br/>in parallel via negamax]
I --> J[Negate opponent scores<br/>to our perspective]
J --> K[Sort descending by score]
K --> L[Return highest<br/>scoring move]
D -->|Layer2Parallel| M[Generate boards<br/>2 moves ahead]
M --> N[Evaluate all boards<br/>in parallel via negamax]
N --> O[Apply layer/checkmate<br/>corrections]
O --> P[Group by root move<br/>and select best]
P --> Q[Return move leading<br/>to best board]
G --> R[Context managers<br/>auto-cleanup resources]
L --> R
Q --> R
Last reviewed commit: 9eca103
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
--null-movedefault changed fromFalsetoTrue). The benchmark already usesnull_move=True, but UCI/Lichess games were playing without it, making the engine significantly weaker in actual play.withstatements) forPoolandManager.self.nodes = 0reset in all parallel enginesearch_movemethods.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