How RollPick rolls fairly

A fair roll needs two things: a good source of randomness, and a correct way to turn it into a die face, a coin side or a name. Here is what happens when you tap Roll.

1. The source: Web Crypto

RollPick asks your browser for random numbers with crypto.getRandomValues. The W3C Web Cryptography specification requires it to be a cryptographically strong generator, and browsers seed it from the operating system (for example /dev/urandom on Linux, or BCryptGenRandom on Windows). Its output is 32-bit whole numbers that are, for any practical purpose, unpredictable.

2. The mapping: rejection sampling

A 32-bit number has 4,294,967,296 possible values. That doesn't divide evenly by 6, or 20, or most other die sizes, so the easy shortcut of taking the remainder gives a few faces a tiny edge. For a d6 that edge is minuscule, but for a large range it can be huge. RollPick instead finds the largest multiple of the range that fits, and draws again whenever the number falls in the leftover slice. The demo below shrinks the generator to 3 bits so you can see the effect.

Try it: turning random bits into a d6

Imagine a generator that only produces 3 random bits, a number from 0 to 7. There are eight values and six faces. What do you do with the extra two?

With the remainder, raw 6 becomes face 1 and raw 7 becomes face 2, so 1 and 2 each come up 25% of the time and 3–6 only 12.5%. That is modulo bias.

3. Shuffles and draws: Fisher–Yates

Lists, raffle draws and no-repeat numbers use the Fisher–Yates shuffle: walk from the end of the list to the start, swapping each item with a uniformly chosen item at or before it. Every ordering is equally likely, which is not true of popular shortcuts like sorting by a random key.

4. From "4d6r1kh3+2" to a number

Before anything is rolled, the expression is split into signed terms (4d6r1kh3, +2) and each dice term into count, sides and modifiers. Limits (100 dice per term, 2–1000 sides) keep a typo from freezing your phone. Each die is then rolled, rerolled once if it shows the reroll value or lower, exploded while it shows its maximum, and finally sorted to keep or drop. The breakdown under the total shows every die, with dropped ones struck through, so any roll can be checked by hand.

5. The animation lands on the result

Dice tumble and coins spin for a moment because it feels right, not because the outcome is still open. The result is drawn first; the animation then settles on it. If your device is set to reduce motion, the animation is skipped entirely.

6. We test it

The site's code ships with automated tests that roll hundreds of thousands of dice and apply a chi-square test to confirm every face turns up as often as it should, check that rejection sampling discards exactly the right values, and verify every dice-notation rule (4d6kh3, 2d20kl1, exploding, rerolls) against known answers.

What RollPick is for

Game nights, classrooms, team picks, raffles and small decisions. It is not built or intended for gambling, and nothing here should be used to place bets.

Questions people ask

Does RollPick use Math.random?

No. Every result uses crypto.getRandomValues, the Web Crypto API's cryptographically secure generator, which browsers seed from the operating system's entropy source.

Is the animation decided in advance?

Yes. The result is drawn the moment you tap, before any animation starts. The tumble or spin is decoration that always finishes on that result, so nothing about timing or when you tap changes the outcome.

Can the site or anyone else change my results?

Rolls happen entirely in your browser. No result is sent to a server, so there is nothing for anyone to adjust. The optional AI roll helper on the dice roller only suggests notation; it never rolls.

Are online dice fairer than real ones?

Usually. Physical dice have small manufacturing imperfections, and hand-tossed coins slightly favour the side that started up. A well-built software generator has no such bias, but it cannot be inspected with calipers, which is why we explain exactly how ours works.