Fix/promotion tag leak#116
Merged
Merged
Conversation
3db93e2 to
76405b9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #116 +/- ##
==========================================
- Coverage 70.33% 70.32% -0.01%
==========================================
Files 27 27
Lines 4187 4186 -1
==========================================
- Hits 2945 2944 -1
Misses 1110 1110
Partials 132 132 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1a56e7a to
101cb40
Compare
76405b9 to
cd7b24b
Compare
cd7b24b to
620aff8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a move-tag “leak” that could occur when reusing a Move struct (notably across promotion variations) by computing tags from scratch rather than mutating/accumulating them on a reused struct.
Changes:
- Replaced
addTags(*Move, *Position)withmoveTags(Move, *Position) MoveTagand updated call sites to assignm.tagsfrom a fresh computation. - Updated/renamed the tag-related unit test and added a regression test ensuring promotion check tags don’t carry across promotion piece types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
notation.go |
Uses fresh tag computation when decoding UCI moves to avoid tag carryover. |
engine.go |
Reworks tag computation into moveTags and updates move generation (including promotions/castling) to assign tags from scratch. |
engine_test.go |
Renames tag test for the new API and adds regression coverage for promotion check-tag isolation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
152
to
156
| } else { | ||
| m.promo = 0 | ||
| addTags(&m, pos) | ||
| if m.HasTag(inCheck) == unsafeOnly { | ||
| m.tags = moveTags(m, pos) | ||
| if m.HasTag(inCheck) == unsafeOnly { | ||
| moves[count] = m |
Comment on lines
+233
to
+236
| // Position where no promotion gives check | ||
| // King on H1 is far from A8, no piece attacks it after promotion | ||
| pos := mustPosition("8/4P3/8/8/8/8/8/7K w - - 0 1") | ||
| moves := pos.ValidMoves() |
620aff8 to
1f1e92c
Compare
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.
No description provided.