fix: Fix index out of bounds in shanten table when encoding 14-tile hands - #178
Merged
Conversation
…ten table overflow
smly
marked this pull request as ready for review
March 14, 2026 15:31
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a panic in shanten/efficiency feature encoding when the encoder is invoked during the tsumo phase (14-tile hands), and adds tooling/docs to validate and describe the feature outputs.
Changes:
- Add
calculate_effective_tiles_auto/calculate_effective_tiles_3p_autoand route shanten-efficiency encoding through them to avoid 15-tile shanten evaluations. - Normalize replay Ankan actions’ consumed tiles to a canonical 4-tile set.
- Expand Python stub docstrings with explicit shapes/dtypes and add a Tenhou log validation script.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/riichienv/_riichienv.pyi | Adds detailed docstrings for observation encoders (shapes/dtypes/examples). |
| scripts/validate_tenhou_logs.py | New end-to-end replay/encoding validator for Tenhou logs (4P/3P). |
| riichienv-core/src/shanten.rs | Adds auto effective-tile helpers and asserts to prevent invalid hand sizes. |
| riichienv-core/src/replay/mod.rs | Canonicalizes Ankan consumed tiles in replay step iterator (4P/3P). |
| riichienv-core/src/observation_3p/python.rs | Switches shanten-efficiency effective-tile calc to the new 3P auto helper. |
| riichienv-core/src/observation_3p/encode.rs | Switches shanten-efficiency effective-tile calc to the new 3P auto helper. |
| riichienv-core/src/observation/python.rs | Switches shanten-efficiency effective-tile calc to the new auto helper. |
| riichienv-core/src/observation/encode.rs | Switches shanten-efficiency effective-tile calc to the new auto helper. |
💡 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.
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.
index out of bounds: the len is 15 but the index is 15) inhash_shupaiwhenencode_shanten_efficiency/encode_extendedis called during tsumo phase (14-tile hand)calculate_effective_tiles_auto/calculate_effective_tiles_3p_autothat correctly handle both 13-tile (3n+1) and 14-tile (3n+2) hands