mahjong.hand_calculating.yaku
Abstract base for yaku pattern detection.
Defines the Yaku base class that every concrete yaku inherits.
Each subclass represents one scoring pattern (e.g., tanyao, riichi, kokushi musou)
and implements is_condition_met() to test whether the pattern is
present in a given hand decomposition.
Concrete yaku are located in the yaku_list
and yakuman packages.
- class mahjong.hand_calculating.yaku.Yaku[source]
Bases:
ABCAbstract base class for all yaku.
Subclasses must set the class attributes below and implement
is_condition_met(). A han value of0means the yaku is unavailable for that hand type (open or closed).>>> from mahjong.hand_calculating.yaku_list import Iipeiko >>> iipeiko = Iipeiko() >>> iipeiko.yaku_id 14 >>> iipeiko.han_open 0 >>> iipeiko.han_closed 1 >>> iipeiko.is_yakuman False >>> str(iipeiko) 'Iipeiko'
- Variables:
yaku_id (int) – unique numeric identifier for this yaku
name (str) – display name of the yaku (e.g.,
"Tanyao","Kokushi Musou")han_open (int) – han awarded when the hand is open;
0if not available for open handshan_closed (int) – han awarded when the hand is closed;
0if not available for closed handsis_yakuman (bool) –
Truefor yakuman-level patterns (13+ han)
- yaku_id: int
Unique numeric identifier for this yaku.
- name: str
Display name of the yaku (e.g.,
"Tanyao","Kokushi Musou").
- han_open: int = 0
Han awarded for open hands.
0means the yaku is not available when the hand is open.
- han_closed: int = 0
Han awarded for closed hands.
0means the yaku is not available when the hand is closed.
- is_yakuman: bool = False
Whether this yaku is a yakuman (worth 13 han or more).
- abstractmethod is_condition_met(hand, *args)[source]
Determine whether this yaku is present in the given hand decomposition.
The base signature accepts only the decomposed hand, but concrete subclasses may require additional positional arguments depending on the yaku. Common extra parameters include:
player_wind/round_wind— for yakuhai wind checkswin_tile,melds,is_tsumo— for yaku that depend on win conditions (e.g., san ankou, suu ankou)tiles_34— for kokushi, which uses the raw count array instead of a decomposed hand
- Parameters:
hand (Collection[Sequence[int]]) – decomposed hand as a collection of tile groups in 34-format
args – additional attributes required by the specific yaku subclass
- Returns:
Trueif the yaku condition is satisfied- Return type:
bool