Skip to main content

yatzy_solver/
lib.rs

1//! # yatzy-solver
2//!
3//! An exact solver, rules engine and stable notation for Scandinavian Yatzy and American rules
4//! (Yahtzee-compatible).
5//!
6//! - [`variant`]: rules as data. [`Variant::scandinavian`] and [`Variant::american`] are built in.
7//! - [`rules`]: the rules engine: legal actions, applying them, scoring and the final score.
8//! - [`notation`]: the canonical text form of states, situations and actions.
9//! - [`solver`]: the exact solver (backward induction) and the within-turn values derived from its table.
10//! - [`table`]: the table file format.
11//! - [`query`]: the value of every option in a situation, best options, regret, batch queries.
12//! - [`simulate`]: seeded games under the optimal policy or a caller's policy.
13//! - [`export`]: sampled situations with every option's value, as JSON Lines or Parquet (feature `parquet`).
14//! - [`verify`]: the brute-force reference solver, reduced games and published values (feature `verify`).
15//!
16//! ```
17//! use yatzy_solver::{Dice, State, Variant};
18//!
19//! let v = Variant::scandinavian();
20//! let dice = Dice::from_faces(&[3, 3, 3, 5, 5]).unwrap();
21//! let sit = v.start_turn(&State::new(), dice).unwrap();
22//! assert_eq!(v.format_situation(&sit), "dice 3 3 3 5 5 | rolls 2 | upper 0 | filled -");
23//! let full_house = v.category_index("full_house").unwrap();
24//! assert_eq!(v.score(full_house, &dice), 19);
25//! ```
26
27pub mod codes;
28pub mod dice;
29pub mod export;
30pub mod notation;
31pub mod query;
32pub mod rules;
33pub mod simulate;
34pub mod solver;
35pub mod table;
36pub mod value;
37pub mod variant;
38#[cfg(feature = "verify")]
39pub mod verify;
40
41pub use dice::Dice;
42pub use notation::NotationError;
43pub use query::{OptionValue, Solver};
44pub use rules::{Action, Game, RulesError, Scored, Situation, State};
45pub use simulate::{Policy, Rng};
46pub use solver::{StateSpace, TurnModel};
47pub use table::{Precision, Table};
48pub use variant::{HouseRules, JokerRule, Variant, VariantDef};