Expand description
A library for calculating the deficiency number (a.k.a. xiangting number, 向聴数).
This library is based on the algorithm in Cryolite’s Nyanten.
However, it introduces the following additional features:
- Supports rules that include and exclude melded tiles when determining if a hand contains four identical tiles.
- Supports three-player mahjong.
§Example
// 123m456p789s11222z
let hand_14: [u8; 34] = [
1, 1, 1, 0, 0, 0, 0, 0, 0, // m
0, 0, 0, 1, 1, 1, 0, 0, 0, // p
0, 0, 0, 0, 0, 0, 1, 1, 1, // s
2, 3, 0, 0, 0, 0, 0, // z
];
let replacement_number = calculate_replacement_number(&hand_14, &None);
assert_eq!(replacement_number?, 0u8);
Enums§
- Claimed
Tile Position - Position of the claimed tile in the melded sequence.
Used in
FuluMianzi::Shunzi
. - Fulu
Mianzi - 副露面子: Meld.
- Invalid
Bingpai Error - Errors that occur when an invalid pure hand (純手牌) is provided.
- Invalid
Fulu Mianzi Error - Errors that occur when an invalid meld is provided.
- Invalid
Shoupai Error - Errors that occur when an invalid hand (手牌) is provided.
Functions§
- calculate_
replacement_ number - Calculates the replacement number (= xiangting number + 1) for a given hand. This function is for 4-player mahjong.
- calculate_
replacement_ number_ 3_ player - Calculates the replacement number (= xiangting number + 1) for a given hand. This function is for 3-player mahjong.
Type Aliases§
- Bingpai
- 兵牌: Hand excluding melds (a.k.a. pure hand, 純手牌).
- Fulu
Mianzi List - List of melds.
- Tile
- 牌: Tile.