mahjong.agari
- class mahjong.agari.Agari[source]
Agari (winning hand) detection.
- static is_agari(tiles_34, open_sets_34=None)[source]
Determine whether the given tiles form a complete hand structure.
Validate the tile arrangement only (4 melds + 1 pair, seven pairs, or thirteen orphans), not yaku or scoring. When open sets are provided, the declared meld tiles are subtracted before checking.
The concealed portion can be passed alone without melds, which is valid for any number of melds (0-4) plus 1 pair:
0 melds + 1 pair (valid hand):
>>> tiles_34 = [0] * 34 >>> tiles_34[0] = 2 >>> Agari.is_agari(tiles_34) True
1 meld (triplet) without a pair is not a valid hand:
>>> tiles_34 = [0] * 34 >>> tiles_34[0] = 3 >>> Agari.is_agari(tiles_34) False
- Parameters:
tiles_34 (Sequence[int]) – hand in 34-format count array (length 34)
open_sets_34 (Collection[Sequence[int]] | None) – declared melds as arrays of tile indices in 34-format
- Returns:
True if the hand is complete
- Return type:
bool