mahjong.hand_calculating
Hand value calculation pipeline.
This subpackage evaluates a winning hand and produces its han, fu, yaku list, and payment amounts. The calculation flows through several stages:
HandDividerdecomposes the hand into all valid block combinations (4 melds + 1 pair, or 7 pairs for chiitoitsu).Yakusubclasses test each decomposition for matching yaku patterns (e.g., tanyao, pinfu, honitsu).FuCalculatorcomputes minipoints from the meld structure, wait type, pair, and winning method.ScoresCalculatorconverts han and fu into payment amounts, accounting for honba and kyoutaku bonuses.
HandCalculator orchestrates the full pipeline and
returns a HandResponse with the
highest-scoring result.
Behavior is controlled by HandConfig, which
specifies win conditions (tsumo/ron), wind context, and optional rule variants such as
open tanyao, aka dora, and double yakuman.
Modules:
- mahjong.hand_calculating.divider
- mahjong.hand_calculating.fu
- mahjong.hand_calculating.hand_config
- mahjong.hand_calculating.hand_response
- mahjong.hand_calculating.hand
- mahjong.hand_calculating.scores
- mahjong.hand_calculating.yaku_config
- mahjong.hand_calculating.yaku
- mahjong.hand_calculating.yaku_list