Skip to content

Fix Mahjong hu check for exposed sets without pair#339

Open
Jiang020609 wants to merge 1 commit into
datamllab:masterfrom
Jiang020609:fix-mahjong-hu-requires-pair
Open

Fix Mahjong hu check for exposed sets without pair#339
Jiang020609 wants to merge 1 commit into
datamllab:masterfrom
Jiang020609:fix-mahjong-hu-requires-pair

Conversation

@Jiang020609
Copy link
Copy Markdown

This fixes a Mahjong hu judgment edge case.

Previously, MahjongJudger.judge_hu returned True whenever len(player.pile) >= 4.
That can mark a hand as winning even when the concealed remaining tiles do not
contain a pair.

Example: after four exposed melds, a remaining hand like [dots-6, bamboo-4]
was judged as hu.

This patch removes the early win return and requires the existing pair-check
path to validate the remaining concealed hand.

Tests added:

  • four exposed sets without a pair should not be hu
  • four exposed sets with a pair should be hu

Local test:
python -m pytest tests/games/test_mahjong_game.py tests/envs/test_mahjong.py

Result:
17 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant