Crate xiangting

Crate xiangting 

Source
Expand description

A library for calculating the deficiency number (a.k.a. xiàngtīng number, 向聴数).

§Example

// 123m456p789s11222z
let hand: [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, &PlayerCount::Four)?;
assert_eq!(replacement_number, 0u8);

Enums§

BingpaiError
Errors that occur when an invalid pure hand (純手牌) is provided.
PlayerCount
The number of players.

Traits§

TileFlagsExt
Extension utilities for working with TileFlags.

Functions§

calculate_necessary_tiles
Calculates the replacement number (= xiàngtīng number + 1) and necessary tiles for a given hand.
calculate_replacement_number
Calculates the replacement number (= xiàngtīng number + 1) for a given hand.
calculate_unnecessary_tiles
Calculates the replacement number (= xiàngtīng number + 1) and unnecessary tiles for a given hand.

Type Aliases§

Tile
牌: Tile.
TileCounts
A type representing the number of tiles for each kind.
TileFlags
A type representing tiles as a bit flag set.