Why naive JavaScript Math.random() % N introduces bias—and how CSPRNG rejection sampling prevents it
Most browser dice rollers rely on Math.floor(Math.random() * sides) + 1. Even worse, quick scripts that reduce a 32-bit integer directly with value % sides introduce subtle modulo bias whenever 2^32 (4,294,967,296) is not evenly divisible by the die size—such as a d6, d10, d12, d20, or d100. Although small on a handful of throws, weak PRNG seeding and unrejected remainders violate strict tabletop auditability across multi-hour campaigns.
NoviDraw generates every polyhedral die face using Web Crypto (crypto.getRandomValues) backed by hardware-seeded entropy and strict rejection sampling. Any Uint32 value falling into the incomplete top tail above floor(2^32 / sides) * sides is discarded and re-sampled automatically, guaranteeing mathematical uniformity across all d4, d6, d8, d10, d12, d20, and d100 outcomes with zero server state or remote RNG calls.
Polyhedral dice statistical baseline, mean values, and Advantage/Disadvantage shifts
| Die / Mechanic | Outcome Range | Exact Expected Mean | Edge Probability Notes |
|---|---|---|---|
| 1d4 / 1d6 / 1d8 | 1–4 / 1–6 / 1–8 | 2.50 / 3.50 / 4.50 | Uniform CSPRNG step: 25.0% / 16.67% / 12.5% per face |
| 1d10 / 1d12 / 1d100 | 1–10 / 1–12 / 1–100 | 5.50 / 6.50 / 50.50 | Exact 1.00% percentile granularity on d100 sweeps |
| 1d20 Flat vs. Advantage (2d20kh1) | 1–20 | 10.50 -> 13.82 (+3.32) | Nat 20 odds rise from 5.00% to 9.75%; Nat 1 drops to 0.25% |
| 1d20 Disadvantage (2d20kl1) | 1–20 | 10.50 -> 7.18 (-3.32) | Rolling 11+ drops from 50.0% to 25.0% exact |
| 4d6 Drop Lowest (4d6kh3) | 3–18 | 12.24 vs. 3d6 10.50 | Full 6-stat array averages ~73.5 total vs. 72 Standard Array |
Worked probability walkthrough: D&D 5e ability rolling & RPG notation expressions
Suppose a Dungeon Master asks every player at Session Zero to generate six stats using 4d6 drop lowest (4d6kh3) instead of the fixed 15, 14, 13, 12, 10, 8 Standard Array. In a single 4d6 throw there are 6^4 = 1,296 equally likely combinations: rolling an 18 requires three or four sixes (21 combinations, or 1.62% per stat vs. 0.46% on 3d6), while rolling a 3 occurs only once in 1,296 throws (0.077%).
For combat encounters, NoviDraw parses multi-term expressions such as 2d20kh1+5, 8d6 (Fireball, 28.00 average damage across an 8–48 spread), or 4d6dl1*6 in one browser pass. Because the complete formula parser runs in client memory, virtual tables can share reproducible roll presets via URL hash without accounts or VTT login walls.
- Critical hit & Save checks: Pair Advantage (2d20kh1) on Flanking or Help actions; rolling 15+ shifts from 30.0% flat to 51.0% probability.
- Fireball / Sneak Attack burst pools: Chain multiple dice sizes like 1d8+4d6+4 directly inside the notation field for instant per-die breakdown badges.
- Session transparency: Copy your roll timestamp and individual die breakdown directly into Discord or Roll20 chat in one click.
Tabletop notation quick-reference for D&D 5e, Pathfinder & board games
Switching cleanly between fast board-game 2d6 movement throws and complex tabletop spell damage prevents typos under initiative pressure. Use the comparison table below to verify notation syntax before locking macro buttons.
Common tabletop notation syntax and practical play applications
| Formula | System / Context | How It Evaluates | Typical Average |
|---|---|---|---|
| 2d20kh1+7 | D&D 5e Advantage Attack | Keeps higher d20, adds +7 proficiency/stat | 20.82 total |
| 2d20kl1+3 | D&D 5e Disadvantage Save | Keeps lower d20, adds +3 modifier | 10.18 total |
| 4d6dl1 | Heroic Ability Score Roll | Rolls 4×d6, drops single lowest die | 12.24 per stat |
| 2d6+6 | 2d6 Apocalypse / Settlers | Uniform two-dice bell curve centered on 7 | 13.00 (7 base) |
- Digital CSPRNG randomness removes physical die manufacturing imbalance (such as rounded resin corners or air bubbles), so high-variance streaks feel rarer or sharper than lightly biased plastic dice.
- Browser refresh resets transient roll history unless you copy your session log or bookmark the URL preset.
- For complex VTT automation with token vision and initiative trackers, pair NoviDraw rolls with dedicated VTT character sheets.
Click 1d20 or enter 10d6 in DevTools with Network logging open. Verify instant local evaluation with 0 HTTP requests, exact per-die chips summing to the displayed total, and changing outcomes on every click.
