yahtzee-engine 0.1.0

Yahtzee rules, scoring, and bots: a fast heuristic and an exact optimal expected-value solver
Documentation
//! The decision procedure a bot (or human front end) implements.

use crate::{Category, TurnAction, View};

/// A decision procedure for playing a turn.
///
/// The engine asks [`choose_action`](Self::choose_action) while rolls
/// remain and [`choose_category`](Self::choose_category) after the third
/// roll, when only scoring is possible — an illegal reroll is
/// unrepresentable there.  The trait is object-safe, so tables can mix
/// strategies via `&mut dyn Strategy`.
pub trait Strategy {
    /// Decides with rolls remaining: hold and reroll, or score now.
    fn choose_action(&mut self, view: &View<'_>) -> TurnAction;

    /// Decides after the final roll: which category to score.
    fn choose_category(&mut self, view: &View<'_>) -> Category;

    /// A short display name for logs and arenas.
    fn name(&self) -> &str {
        "unnamed"
    }
}