dou_dizhu

Crates.iodou_dizhu
lib.rsdou_dizhu
version0.2.0
created_at2025-08-15 11:23:17.062165+00
updated_at2025-08-24 14:44:23.719112+00
descriptionRust toolkit for the Chinese card game Dou Dizhu (斗地主)
homepage
repositoryhttps://github.com/zhangheqi/dou_dizhu
max_upload_size
id1796589
size67,484
(zhangheqi)

documentation

README

dou_dizhu

Crates.io Documentation License

A Rust toolkit for the Chinese card game Dou Dizhu (斗地主).

This crate implements Dou Dizhu strictly following the Pagat rules, though it uses different terminology.

Features

  • Hand representation
  • Compile-time and runtime validation
  • All standard Dou Dizhu play kinds (solo, pair, trio, chain, airplane, rocket, etc.)
  • Play kind recognition
  • Play comparison
  • Enumerating all plays of specified characteristics within a hand

Usage

Add this to your Cargo.toml:

[dependencies]
dou_dizhu = "0.2"

Then:

use dou_dizhu::*;

fn main() {
    // Construct a play
    let airplane_with_solos = play!(const {
        Queen: 3,
        King: 3,
        Three,
        Four,
    })
    .unwrap();

    // Count how many stronger plays of the same kind exist in a full deck
    assert_eq!(
        Hand::FULL_DECK
            .plays(airplane_with_solos.kind())
            .filter(|p| p > &airplane_with_solos)
            .count(),
        77,
    );
}

License

Licensed under either of:

at your option.

Commit count: 16

cargo fmt