A single draw
- Input
- 1 rodada, sem melhor de N
- Expected output
- 'sim' ou 'não', 50% de chance cada lado
A single call to flipOnce, with no history of earlier rounds to consult, always the exact same odds on both sides.
yes or no quick decision maker
Beating decision paralysis with a yes or no sounds silly until you understand the mechanism behind it: a fair binary draw, with the option to run it several times and keep whichever result came up more. This page explains that draw, the best-of-N rounds mode, and why a streak of "yes" in a row does not change the odds of the next round.
A single call to flipOnce, with no history of earlier rounds to consult, always the exact same odds on both sides.
4 is even, so the code adds 1 before drawing, guaranteeing it never lands 2-2 with no winner.
The real total of draws is always odd after the correction, so the count of yes plus no never closes in a tie.
Yes. Each decision uses `crypto.getRandomValues`, the browser's cryptographic random number generator, with bias correction. The chance of yes and no is exactly the same, 50% each.
Because the code forces any even round count up to the next odd number by adding 1. With 4 rounds at 50% odds each side, a 2-2 tie would be possible; forcing 5 guarantees one side always has a majority.
No. Every draw is independent and the code never checks the history of earlier rounds to weight the next one. The odds stay exactly 50/50, even after any streak of identical results.
Yes, every decision draws a 32-bit integer with crypto.getRandomValues and applies modulo 2. Since the total count of 32-bit values is even, this particular modulo introduces no bias between the two possible sides.
No. The code always converts the requested round count to the next odd value before drawing, so the sum of yes plus no can never close equal, one side always ends with at least one more vote.