piech 0.1.0

A hidden-information Daifugo engine for human and humanoid players
Documentation
  • Coverage
  • 100%
    102 out of 102 items documented1 out of 47 items with examples
  • Size
  • Source code size: 37.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 778.8 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

piech

piech is a dependency-free Rust game engine for letting humans and humanoid controllers play Daifugo (Japanese President) through the same interface.

use piech::{Controller, Game, Player, Rules};

let players = [
    Player::new("us", Controller::Human)?,
    Player::new("robot", Controller::Humanoid)?,
];
let mut game = Game::deal(players, piech::standard_deck(1)?, Rules::default())?;
let current = game.current_player_id().unwrap().to_owned();
let action = game.view_for(&current)?.legal_actions()[0].clone();
game.apply(&current, action)?;
# Ok::<(), piech::Error>(())

Game principles

  • Human and humanoid seats use identical observations and actions.
  • Each player sees only their hand, opponent card counts, and public state.
  • Legal actions are generated by the engine, making agent integration direct.
  • The Agent trait lets a humanoid, AI, or human UI take a validated turn from its private PlayerView.
  • Values remain deterministic; callers provide the shuffled deck order.
  • Singles and same-rank groups of up to four cards are supported.
  • Jokers can act as configurable wildcards in groups.
  • Four-card groups can toggle revolution.
  • Eights can clear the trick and retain the lead.
  • A lone three of spades can beat a lone joker.
  • Players who pass stay out until the trick clears.
  • The engine determines every finishing position, including the final player.

Rule scope

Daifugo rules vary widely. Version 0.1 intentionally does not implement straights, suit lock, eleven-back, five-skip, card exchange, or forbidden finishes. Applications should present the configured rule set to every player before play and must not assume unsupported local rules.

The crate performs no networking, random-number generation, robot motion, or model inference. It has no external dependencies and uses no unsafe code.

Licensed under MIT.