Terug naar blog
Behind the Scenes5 min read

How We Built a Fair Wheel (And Why True Randomness Matters)

When we built Namespinner, we had a choice about how to generate the random result of each spin. We could use the built-in random number generator that comes with JavaScript—simple, fast, and good enough for most purposes—or we could use the browser's cryptographic random number generator, which is slower to call but produces genuinely unpredictable results. We chose the latter, and it's worth explaining why that decision matters.

Two Types of Randomness

Most programming languages include a function called something like Math.random(). This function returns a number between 0 and 1 that appears random—meaning it has no obvious pattern and is distributed roughly evenly across the range. For casual uses like simulations, shuffling playlists, or adding variety to a game, it's perfectly adequate.

But Math.random() is a pseudorandom number generator. It starts from a "seed"—an initial value, often derived from the current time in milliseconds—and applies a mathematical formula to produce a sequence of numbers. The sequence looks random, but it isn't truly random. If you knew the seed and the formula, you could predict every number in the sequence. In practice, this is very hard to do, but it's theoretically possible.

Cryptographic random number generators are different. They use genuinely unpredictable sources—noise from hardware, timing irregularities in the processor, environmental data collected by the operating system—to produce numbers that cannot be predicted, even with full knowledge of the system state. The browser exposes this as crypto.getRandomValues(), and it's the same underlying source used to generate encryption keys and secure tokens.

Why It Matters for a Wheel Spinner

For most of the things people use Namespinner for—picking who answers a question in class, deciding where to eat dinner—the difference between pseudorandom and cryptographic randomness is academic. Nobody is going to reverse-engineer the seed to predict your dinner choice.

But for giveaways, raffles, and competitions where a prize changes hands and the fairness of the selection can be questioned, the distinction matters. If a participant believes the wheel could be manipulated—or even just suspects it—that suspicion undermines the whole point of using a visible draw to establish trust. A wheel that uses cryptographic randomness isn't manipulable, not because we say so, but because the randomness comes from hardware entropy that nobody controls.

Using crypto.getRandomValues() also means the result can't be predicted from the timing of the spin. Some pseudorandom generators seed from the system clock, which means spinning at a known millisecond value could in principle predict the result. Cryptographic randomness breaks this connection entirely.

How the Spin Mechanic Works

When you click the wheel to spin, here's what actually happens under the hood. First, we generate a cryptographically random number and map it to a rotation amount—essentially choosing a final angle from a range of thousands of possible positions. This determines where the wheel will stop.

The visual spin is calculated from that final position backward: how fast does the wheel need to start spinning, and how quickly does it decelerate, to land exactly on that angle after a plausible-looking rotation? The spin is real—it's not a predetermined slow-down onto a result—but the endpoint is selected before the animation begins. The wheel always stops where the random number says it should stop.

This means the visual length of the spin has no effect on the result. Spinning "harder" or "softer" doesn't change anything. The result was determined the moment you clicked.

Segment Sizes and Probability

Each segment on the wheel corresponds to exactly one entry. If you have ten entries, each has a one-in-ten chance of winning. If you add a name three times (for a participant with three entries in a weighted draw), they have three-in-ten chance—exactly three times the probability of someone with one entry.

The wheel doesn't use segment visual size to determine probability. It uses the count of entries in the list. A segment that appears smaller because the wheel is crowded with entries has exactly the same probability as a segment that appears larger on a wheel with fewer entries. Visual size is for readability; probability is determined by entry count.

Offline and Privacy

Namespinner is built as a Progressive Web App, which means it works after the initial page load even without an internet connection. Your names stay in your browser's local storage—they're never sent to our servers. We don't store entry lists, spin results, or any identifiable information from your sessions.

This matters for schools and organizations with data policies. A class list of student names that lives only in your browser, on your device, is categorically different from a list stored in a third-party cloud database. We made this choice deliberately.

What We're Still Working On

Randomness is the core of what Namespinner does, and we take it seriously. We're continuing to audit and improve the implementation as browsers evolve. If you have questions about how the wheel works technically, or if you spot something that doesn't seem right, the feedback button in the footer connects directly to us. We'd rather hear about a problem early than have it undermine trust in a draw that matters to someone. Try the spinner here—see for yourself what genuinely random looks and feels like.