#renderer #mahjong #riichi

riichi_hand

A collection of utilities for working with Riichi Mahjong player hands

9 releases (5 breaking)

0.6.2 Apr 1, 2024
0.6.1 Jan 14, 2024
0.6.0 Jul 11, 2023
0.5.0 Jul 4, 2023
0.1.0 Jan 21, 2022

#231 in Game dev

Download history 171/week @ 2024-01-01 19/week @ 2024-01-08 42/week @ 2024-01-22 87/week @ 2024-01-29 40/week @ 2024-02-05 32/week @ 2024-02-12 61/week @ 2024-02-19 133/week @ 2024-02-26 20/week @ 2024-03-04 4/week @ 2024-03-11 273/week @ 2024-04-01

279 downloads per month

MIT license

1.5MB
2.5K SLoC

riichi-hand-rs

Rust Build Status crates.io Documentation MIT licensed codecov

A collection of utilities for working with Riichi Mahjong player hands to use with Rust programming language.

This currently includes:

  • Hand representation object
  • Parser that allows to quickly create a hand using human-readable string, such as 123m456p_7*77z
  • Renderer that allows to draw a hand to a raster image (along with a few ready-to-use sets of tile images)
  • Points calculator (i.e. scoring table and an ability to calculate Aotenjou points with optional BigInt support)

Usage

Add the following to your Cargo.toml:

[dependencies]
riichi_hand = "0.6.2"

On the feature flags overview, please refer to the crate documentation.

Example

use riichi_hand::parser::HandParser;
use riichi_hand::raster_renderer::fluffy_stuff_tile_sets::YELLOW_FLUFFY_STUFF_TILE_SET;
use riichi_hand::raster_renderer::{RasterRenderer, RenderOptions};

fn main() {
    let hand = HandParser::parse("123m123p123sEESS").unwrap();
    let image = RasterRenderer::render(&hand, &*YELLOW_FLUFFY_STUFF_TILE_SET, RenderOptions::default());
    image.save("/tmp/hand.png").unwrap();
}

This results in the following image being generated:

Test hand: 1, 2, 3 manzu, 1, 2, 3 pinzu, 1, 2, 3 souzu, 2 easts, 2 souths

Uses

  • chombot - Discord bot for Krakow Chombo Club's Discord server
  • chombo-gen - Web-based hand renderer

License

The project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the project by you shall be licensed as MIT, without any additional terms or conditions.

Attribution

This project uses modified riichi-mahjong-tiles by FluffyStuff, licensed under CC BY 4.0.

This project uses mahjong tiles by Martin Persson which are free for personal and commercial use under the condition that a link to the author's page is provided.

Dependencies

~0.1–2.7MB
~13K SLoC