Skip to content

fix: reinit wall.drawable_count in StartKyoku replay handler#203

Merged
smly merged 3 commits into
mainfrom
fix/issue-198-replay-drawable-count
Apr 26, 2026
Merged

fix: reinit wall.drawable_count in StartKyoku replay handler#203
smly merged 3 commits into
mainfrom
fix/issue-198-replay-drawable-count

Conversation

@smly
Copy link
Copy Markdown
Owner

@smly smly commented Apr 26, 2026

Fixes #198.

  • Resets wall.drawable_count to wall.tiles.len() - 14 inside the StartKyoku arm of apply_mjai_event so it matches the invariant established by _initialize_round. Applies the same fix to the 3P replay handler.
  • Adds regression coverage.

@smly smly self-assigned this Apr 26, 2026
@smly smly added bug Something isn't working core replay labels Apr 26, 2026
@smly smly requested a review from Copilot April 26, 2026 10:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a replay-only state initialization bug where StartKyoku rebuilt the wall tiles but left wall.drawable_count stale, which could incorrectly suppress Riichi (and other actions gated by remaining draws) in observe_event replays.

Changes:

  • Reinitialize wall.drawable_count in apply_mjai_event(StartKyoku) to wall.tiles.len() - 14 for both 4P and 3P replay handlers to match _initialize_round.
  • Add regression tests asserting drawable_count resets correctly and that Riichi appears in legal actions in replay scenarios for both variants.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
riichienv-core/src/state/event_handler.rs Reset wall.drawable_count during 4P StartKyoku replay initialization to restore legality invariants.
riichienv-core/src/state_3p/event_handler.rs Same drawable_count reset for 3P StartKyoku replay initialization.
riichienv-core/src/tests.rs Add regression coverage for drawable_count reset and Riichi availability in replay paths (4P/3P).

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

Comment thread riichienv-core/src/state_3p/event_handler.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@smly smly merged commit 667e7aa into main Apr 26, 2026
7 checks passed
@smly smly deleted the fix/issue-198-replay-drawable-count branch April 26, 2026 14:30
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 replay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

observe_event replay path: reach missing from legal actions

2 participants