ritchie/elements/tile_set34

Histogram for all 34 kinds of tiles.

Types

pub opaque type TileSet34

Values

pub fn add(set: TileSet34, t: tile.Tile, delta: Int) -> TileSet34

Adds a delta (may be negative) to a tile’s count. Panics on under/overflow.

pub fn complete_set() -> TileSet34

The complete set of tiles in a game.

pub fn count(set: TileSet34, t: tile.Tile) -> Int

Returns how many of the given tile are in the set.

pub fn empty() -> TileSet34
pub fn from_bit_array(bits: BitArray) -> Result(TileSet34, Nil)

Wrap an existing bit array. Must be exactly 34 bytes.

pub fn from_list(counts: List(Int)) -> Result(TileSet34, Nil)

Builds a tile set from a list of all counts, each in 0..=255.

pub fn from_tiles(tiles: List(tile.Tile)) -> TileSet34

Counts every tile in the list, and returns it as a tile set.

pub fn set_count(
  set: TileSet34,
  t: tile.Tile,
  n: Int,
) -> TileSet34

Replaces the count for a tile. Panics if n isn’t in 0..=255.

pub fn to_bit_array(set: TileSet34) -> BitArray

Returns the inner bit array.

pub fn to_list(set: TileSet34) -> List(Int)

Returns all counts as a list, in encoding order.

pub fn to_string(set: TileSet34) -> String

Renders as four comma-terminated groups: manzu, pinzu, souzu, honors e.g. "300000000,000000000,000000000,0000000,"

pub fn to_suit_list(set: TileSet34) -> List(List(tile.Tile))
pub fn to_tiles(set: TileSet34) -> List(tile.Tile)

Returns the set as a list of all tiles in this set, in encoding order (i.e. reds come after honors).

✨ Search Document