The wheel already knows
Why the winner is drawn before the animation starts, and what that buys you.
Press Spin and the wheel turns for ten seconds. It looks like the answer is being decided somewhere in those ten seconds — in the deceleration, in the last half-turn, in whether the pointer just clears one more divider.
It is not. The winner is drawn first, in a few microseconds, and the animation is then aimed at it.
Why that order
The obvious alternative is to spin the wheel and read off wherever it stops. It sounds fairer — nobody chose, physics did — and it is the harder thing to defend, because it turns every question about fairness into a question about the animation.
Can you flick harder and change the answer? Does clicking mid-spin to bring it
in early bias the result? What happens for someone browsing with
prefers-reduced-motion turned on, who never sees the animation at all?
Draw first and all three have the same answer: no, because the draw already happened. The flick buys extra turns. The early click shortens the travel. Reduced motion skips the travel entirely and announces the result straight away. Three different journeys through one piece of code, rather than three branches that each have to be argued about separately.
What does the drawing
The entropy is crypto.getRandomValues — the browser's own cryptographic
generator — and never Math.random.
Getting a uniform number out of it takes one more step than it looks like it
should. The obvious draw % count is biased whenever count does not divide
2³² evenly: the first few entries each get one extra chance out of four billion.
Small, but it is a thumb on the scale, and a wheel that claims to be fair should
not have one. So draws that land in the leftover tail are thrown away and
another one is taken.
const limit = Math.floor(2 ** 32 / max) * max;
let draw = crypto.getRandomValues(new Uint32Array(1))[0];
while (draw >= limit) {
draw = crypto.getRandomValues(new Uint32Array(1))[0];
}
return draw % max;
That costs an occasional extra draw and buys an exactly uniform result. The same code is on the fairness page, where it is the copy rather than an illustration of it.
Weights are odds, not favourites
Give an entry a weight of 3 and it takes three shares of the draw instead of one. The wheel draws it as a wider sector, and the list shows the percentage that weight actually buys, so nobody has to divide by hand.
Two entries with the same text stay two entries. They each keep their own chance, and the list says how many repeats it found rather than quietly merging them — halving somebody's odds without telling them is the kind of helpfulness nobody asked for.
What the animation is still for
An aimed animation is not a fake one. The wheel really does travel to the sector it lands on, the ticks really are timed to the dividers it passes, and the near-miss hesitation — when you turn it on — hangs on a neighbour of the winner rather than on a random sector, then carries on to the entry that was drawn before any of it started.
The suspense is real. The result is just older than it looks.