Fix Simulator for west-round terminal states#196
Fix Simulator for west-round terminal states#196tsubakisakura wants to merge 2 commits intosmly:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Simulator.get_next_state() terminal-state detection in continue mode by basing the “final hand and later” check on a zero-indexed kyoku value, ensuring West-round states (e.g., W2) are handled as terminal when appropriate, and adds a guard to treat start_game/end_game-only logs as a clean finish.
Changes:
- Add a guard to return
None(clean finish) when a continue-mode log contains onlystart_game/end_gameevents. - Convert
(bakaze, kyoku)to a unifiedzero_indexed_kyokuearlier and use it for terminal (“オーラス以降”) detection. - Remove redundant late conversion by reusing
zero_indexed_kyokufor subsequent next-state computation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # start_game/end_game without any kyoku in continue mode. | ||
| # Treat them as a clean finish, not a runtime error. | ||
| event_types = {event["type"] for event in events} | ||
| if event_types.issubset({"start_game", "end_game"}): |
There was a problem hiding this comment.
event_types.issubset({"start_game", "end_game"}) is also True for an incomplete log that contains only start_game (or even an empty events list), which would be treated as a clean finish and could mask real failures. Consider requiring that end_game is actually present (e.g., check that event_types == {"start_game","end_game"} or at least that both types exist) before returning None.
| if event_types.issubset({"start_game", "end_game"}): | |
| if event_types.issubset({"start_game", "end_game"}) and "end_game" in event_types: |
There was a problem hiding this comment.
指摘ありがとうございます!get_next_state() が呼ばれる条件を精査します。
| # 南1局 → `4` のようにゼロ基準の値に変換する | ||
| zero_indexed_kyoku = kyoku_to_zero_indexed_kyoku(bakaze, kyoku) | ||
| if zero_indexed_kyoku >= 7: |
There was a problem hiding this comment.
This changes the terminal-state logic to use zero_indexed_kyoku >= 7 (covering West-round hands too), but there doesn’t appear to be a regression test that exercises a West-round continuation (e.g., W1/W2) and asserts get_next_state() returns None when it should. Adding a focused unit/integration test in tests/test_game_simulator.py for a West-round terminal scenario (and the new start_game/end_game-only case) would help prevent future regressions.
There was a problem hiding this comment.
@tsubakisakura これは恥ずかしい見落とし... 修正ありがとうございます!Copilot のコメントしている regression test は不要です。
Summary
Why
再現コード