eurydice_engine 0.1.0

Dice probability engine implementing the AnyDice language, using the Icepool algorithm
Documentation

eurydice_engine

The dice probability engine used by Eurydice, an implementation of the AnyDice language.

use eurydice_engine::Engine;

let mut engine = Engine::new();
let report = engine.run_source("output 2d6 named \"roll\"");

assert!(report.diagnostics.first_error().is_none());
assert_eq!(report.outputs[0].name, "roll");
assert_eq!(
    report.outputs[0].distribution.entries().next(),
    Some(([2].as_slice(), 1.0 / 36.0)),
);

The language is documented in the Eurydice specification; it is a near-strict superset of AnyDice, documented at the AnyDice docs

Probabilities are computed exactly with rational arithmetic and converted to f64 only at the end. When possible, computation uses the Icepool algorithm.[^1]

This crate offers no real extension points today, but methods to have the host program insert new primitives or modify the AST are planned.

Features

serde derives Serialize on the public report types. Enable it when a frontend needs to serialize engine results.

This project is not affiliated with AnyDice

AnyDice was created by Jasper Flick. This is an independent reimplementation of its language.

License

Apache-2.0.

[^1]: Liu, A. J. (2022). Icepool: Efficient Computation of Dice Pool Probabilities. Proceedings of the AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment, 18(1), 258-265. https://doi.org/10.1609/aiide.v18i1.21971