What it does
createDicePool takes a seed and a list of dice. A die is a list of faces, each with a number or a string as its
value, an optional label, and a weight that defaults to 1. standardDie builds the familiar fair ones, a d6, a d20
or a d100, and a pool can mix any of them. roll rolls every unheld die, or a chosen few, and hold keeps a rolled
die's face for the next roll; release clears every hold at the end of a turn. Each roll returns an ordered event
with every face that changed, ready to animate.
Rolls draw from the engine's seeded random stream, held inside the pool. snapshot saves the dice, the faces showing,
the holds and the stream's state; restore checks the save against the pool before changing anything, and the next
roll is the same as it would have been. Commands passed through apply can be recorded and replayed from a fresh pool
with the original options, so a game can restart or show an animated replay without inventing outcomes. A selection
that is refused, a held die or a duplicate, consumes no randomness.
diceProbability enumerates every outcome of a set of dice, with their weights, and returns the chance that your
test is true: three sixes, at least two hits, a sum over 15. diceSumDistribution gives the chance of every total.
Both answer only after the whole calculation fits within a budget, and otherwise say the budget ran out rather than
guess.
Features
- Any face — numbers, including negatives, or symbols such as attack and defend, with display labels.
- Weighted faces — any positive weight, for loaded or uneven dice.
- Mixed pools — up to 64 dice of up to 256 faces each, of any sizes together.
- Holds — keep chosen dice and roll the rest, as in a five-dice scoring game.
- Reproducible rolls — seeded, with saves that restore the exact next roll.
- Replayable commands — roll, hold and release as data, for recording, replay and persistence.
- Exact probabilities — the chance of any predicate, and the full distribution of sums, within a budget.
- Safe observations —
observationshows the faces and holds without the random state, for hints and bots.
Good for
- Five-dice scoring games — roll, hold and roll again, with the odds for an advice feature.
- Tabletop RPG checks — a d20 with modifiers, a d100 table, or damage dice of mixed sizes.
- Board games with custom dice — symbol dice for combat, movement or resources.
- Push-your-luck dice games — roll, keep what you like and risk the rest, with the odds shown.
- Probability tools — show the player their exact chance of success before they roll.
- Bots and hints — fair advice from the visible faces, never from the future rolls.
Make it yours
There are no pack options; every pool is defined by its seed and dice. A classic game might be five plain d6 held
and re-rolled up to three times, with the turn limit and scorecard written by the game. A fantasy battle might mix a
d20 for damage with a symbolic effect die whose faces are three hits to one guard, and ask diceProbability for the
chance of at least two hits before the player commits.
A quick look
A mixed pool of a d20 and a weighted symbol die, rolled, with the d20 held for the next roll:
const dice = game.diceCore.createDicePool({ seed: 29, dice: [
game.diceCore.standardDie('damage', 20),
{ id: 'effect', faces: [
{ id: 'hit', value: 'attack', weight: 3 },
{ id: 'guard', value: 'defend', weight: 1 },
] },
] });
dice.apply({ kind: 'roll' });
dice.apply({ kind: 'hold', id: 'damage', held: true });
dice.roll(); // Rolls only unheld dice.
Works with
yahtzee— classic and triple five-dice scoring, matches and advice, built on this pool.geometry-3d— polyhedral dice meshes, for showing the faces in 3D.
Good to know
- There is no physics: a roll is a weighted random choice, and your game animates the dice however it likes.
- Scoring, turns, reroll limits, hidden dice and exploding dice are not here; they belong to the game.
- "Exact" means every outcome was counted; the arithmetic is ordinary floating point.
- The generator is for games, not for cryptography or regulated gambling.
- Probability budgets default to 100,000 operations and go up to a million.






