Expand description
§yatzy-solver
An exact solver, rules engine and stable notation for Scandinavian Yatzy and American rules (Yahtzee-compatible).
variant: rules as data.Variant::scandinavianandVariant::americanare built in.rules: the rules engine: legal actions, applying them, scoring and the final score.notation: the canonical text form of states, situations and actions.solver: the exact solver (backward induction) and the within-turn values derived from its table.table: the table file format.query: the value of every option in a situation, best options, regret, batch queries.simulate: seeded games under the optimal policy or a caller’s policy.export: sampled situations with every option’s value, as JSON Lines or Parquet (featureparquet).verify: the brute-force reference solver, reduced games and published values (featureverify).
use yatzy_solver::{Dice, State, Variant};
let v = Variant::scandinavian();
let dice = Dice::from_faces(&[3, 3, 3, 5, 5]).unwrap();
let sit = v.start_turn(&State::new(), dice).unwrap();
assert_eq!(v.format_situation(&sit), "dice 3 3 3 5 5 | rolls 2 | upper 0 | filled -");
let full_house = v.category_index("full_house").unwrap();
assert_eq!(v.score(full_house, &dice), 19);Re-exports§
pub use dice::Dice;pub use notation::NotationError;pub use query::OptionValue;pub use query::Solver;pub use rules::Action;pub use rules::Game;pub use rules::RulesError;pub use rules::Scored;pub use rules::Situation;pub use rules::State;pub use simulate::Policy;pub use simulate::Rng;pub use solver::StateSpace;pub use solver::TurnModel;pub use table::Precision;pub use table::Table;pub use variant::HouseRules;pub use variant::JokerRule;pub use variant::Variant;pub use variant::VariantDef;
Modules§
- codes
- The action code space: a fixed integer code for every action that can be legal in a variant, for batch
arrays and learners with a fixed output layout. Part of the stable notation contract (
docs/notation.md). - dice
- Dice as sorted multisets.
- export
- Export (F5): sampled situations with the exact value of every option, as JSON Lines (and Parquet with the
parquetfeature). The schema is documented indocs/export.md. - notation
- The stable text notation (F6) for states, situations and actions.
- query
- Queries (F2) and batch queries (F3): the exact value of every option in any situation.
- rules
- The rules engine (F7): legal actions, applying them, scoring, game over and the final score.
- simulate
- Simulation (F4): play games with a seeded random generator, under the optimal policy or a caller’s policy.
- solver
- The exact solver: backward induction over the states between turns (SPEC 3).
- table
- The table file (F1, SPEC 5.4): a header, the value array in
StateSpaceorder, and a SHA-256 checksum. - value
- The number type of expected values.
- variant
- Variants: rules as data.
- verify
- Verification tools (F8): a brute-force reference solver for reduced games, the reduced games themselves, and the published values.