Skip to content

fix(shanten): correct ukeire over-counting by subtracting hand tile copies - #174

Merged
smly merged 5 commits into
mainfrom
fix/feat-shanten
Mar 14, 2026
Merged

fix(shanten): correct ukeire over-counting by subtracting hand tile copies#174
smly merged 5 commits into
mainfrom
fix/feat-shanten

Conversation

@smly

@smly smly commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Resolves #173

The ukeire calculation only subtracted visible_counts (discards, melds, dora indicators) from the 4-copy total, ignoring tiles already in the player's own hand. This caused remaining-copy counts to be inflated (e.g. 4 instead of 1 when holding 3 copies with 0 visible).

@smly smly self-assigned this Mar 13, 2026
@smly smly added bug Something isn't working core labels Mar 13, 2026
@smly
smly requested a review from Copilot March 13, 2026 17:14

Copilot AI 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.

Pull request overview

Fixes an over-counting bug in shanten “ukeire” (improving-tile remaining-copies) calculations by subtracting copies already in the player’s hand, aligning the feature values with actual remaining tile availability.

Changes:

  • Precompute hand tile-type counts once and reuse them across iterations for both 4P and 3P code paths.
  • Correct ukeire remaining-copy calculation to subtract in-hand counts in addition to visible counts.
  • Add basic regression tests for 4P/3P ukeire paths under the python feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread riichienv-core/src/shanten.rs Outdated
Comment thread riichienv-core/src/shanten.rs Outdated
Comment thread riichienv-core/src/shanten.rs
Comment thread riichienv-core/src/shanten.rs Outdated
@smly

smly commented Mar 13, 2026

Copy link
Copy Markdown
Owner Author

I'll validate against actual tenhou game logs before merging, just to be safe.☺️

@smly
smly merged commit acb3825 into main Mar 14, 2026
7 checks passed
@smly
smly deleted the fix/feat-shanten branch March 14, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(shanten): Refactor shanten efficiency tile-count guards and simpler counting logic

2 participants