Skip to content

Add conservative LMR and skip NMP based on static#437

Merged
bdmendes merged 6 commits into
masterfrom
tighten
Apr 19, 2026
Merged

Add conservative LMR and skip NMP based on static#437
bdmendes merged 6 commits into
masterfrom
tighten

Conversation

@bdmendes

@bdmendes bdmendes commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Improved search engine internals: tighter pruning conditions and refined null-move handling to reduce wasted search branches.
    • Fewer redundant lookups and improved move-ordering heuristics.
    • New late-move reduction logic and adjusted depth reductions for certain quiet moves, yielding more efficient and consistent search performance.

@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a14f3595-2ee0-4586-a98d-00ffc9e23f99

📥 Commits

Reviewing files that changed from the base of the PR and between 29d617b and e03fbb9.

📒 Files selected for processing (1)
  • src/search/mod.rs

Walkthrough

Tightens null-move gating to require a window cutoff against static_evaluation + MAX_POSITIONAL_WEIGHT, caches hash_move for reuse, introduces a may_late_move_reduce condition for quiet/non-frontier moves, increases null-search reduction for certain late quiet moves, and simplifies window-based return logic.

Changes

Cohort / File(s) Summary
Search core
src/search/mod.rs
Require window.cuts_off(static_evaluation + MAX_POSITIONAL_WEIGHT) for null-move eligibility; compute and pass a single hash_move = self.table.hash_move(position) into MovePicker::new(...); add may_late_move_reduce for non-frontier/quiet or absent hash moves; apply an extra depth subtraction for quiet moves with i > 5; remove window.cuts_off(null_score) gating and use window.improves(null_score) only.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰
I cached a hop, one hash to find,
Trimmed a branch that wasted time.
Quiet steps reduced at late-night tide,
Window checks guide which paths to hide.
Happy hops — the search runs spry! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding conservative late-move reduction (LMR) and skipping null-move pruning (NMP) based on static evaluation criteria.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b377f43c-5e6b-4ae5-9529-dae22c6508eb

📥 Commits

Reviewing files that changed from the base of the PR and between 789450f and 7baf809.

📒 Files selected for processing (4)
  • src/position/piece.rs
  • src/search/mod.rs
  • src/search/picker.rs
  • src/search/see.rs

Comment thread src/search/mod.rs Outdated
Comment thread src/search/see.rs
@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92%. Comparing base (be20971) to head (e03fbb9).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff          @@
##           master   #437   +/-   ##
=====================================
+ Coverage      92%    92%   +1%     
=====================================
  Files          33     33           
  Lines        3757   3760    +3     
  Branches     3757   3760    +3     
=====================================
+ Hits         3419   3422    +3     
  Misses        319    319           
  Partials       19     19           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/search/mod.rs (1)

234-244: ⚠️ Potential issue | 🟠 Major

Verify reduced fail-highs at full depth.

After Line 234 reduces late quiet moves, a reduced search that returns >= beta skips the full-depth re-search because Line 243 excludes cutoffs. That lets Line 246 feed a shallow score into Line 252 and prune the node based on an unverified reduced-depth result.

🐛 Proposed fix
-                let reduction = if may_late_move_reduce && mov.is_quiet() && i > 5 { 1 } else { 0 };
+                let full_depth = depth.saturating_sub(1);
+                let reduction = if may_late_move_reduce && mov.is_quiet() && i > 5 { 1 } else { 0 };
 
                 let null_score = -self.pvs(
                     &next_position,
-                    depth.saturating_sub(1).saturating_sub(reduction),
+                    full_depth.saturating_sub(reduction),
                     ply.saturating_add(1),
                     window.reverse_null_around_alpha(),
                 );
 
-                if window.improves(null_score) && !window.cuts_off(null_score) {
-                    -self.pvs(&next_position, depth.saturating_sub(1), ply.saturating_add(1), window.reverse())
+                if window.improves(null_score) && (reduction > 0 || !window.cuts_off(null_score)) {
+                    -self.pvs(&next_position, full_depth, ply.saturating_add(1), window.reverse())
                 } else {
                     null_score
                 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1a30aef-622b-4865-937b-bab57d602ab8

📥 Commits

Reviewing files that changed from the base of the PR and between 7baf809 and 29d617b.

📒 Files selected for processing (1)
  • src/search/mod.rs

@github-actions

github-actions Bot commented Apr 19, 2026

Copy link
Copy Markdown

Against master [hash=64]: 🆗 Elo: 5.56 +/- 18.74, nElo: 6.40 +/- 21.53

@github-actions

github-actions Bot commented Apr 19, 2026

Copy link
Copy Markdown

Against v1.6.0 [hash=64]: ✅ Elo: 75.15 +/- 18.68, nElo: 89.46 +/- 21.53

@bdmendes bdmendes merged commit 4d4486c into master Apr 19, 2026
8 checks passed
@bdmendes bdmendes deleted the tighten branch April 19, 2026 22:04
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.

1 participant