Fair Randomness: Seeds, Shuffles and Pity Timers
True randomness feels rigged to players. Seeds, shuffle bags and pity timers give you randomness that surprises without producing streaks nobody believes.

Key takeaways
- Use a seeded random generator, one stream per system, so runs can be replayed, daily challenges match for everyone and bugs can be reproduced.
- Shuffle bags guarantee every outcome appears within a cycle; pity timers guarantee a rare outcome after N misses. Both remove the streaks that feel unfair.
- Players misjudge probability, especially high ones. A shown 90 percent that misses feels broken, so decide deliberately whether displayed odds are exact or quietly generous.
Fair randomness in games means randomness players believe: outcomes that surprise them without long streaks of bad luck that feel rigged. Pure random numbers do not deliver that, because real randomness clusters. The standard toolkit is small: a seeded generator so results are reproducible, shuffle bags that guarantee each outcome shows up within a cycle, pity timers that guarantee a rare outcome after enough misses, and a deliberate policy on how honest displayed odds are. Most games that feel fair use at least two of these.
Why true randomness feels unfair
Flip a fair coin 100 times and a run of six or more heads in a row is more likely than not. In a game, that run is six missed attacks or six drops without the item you need, and players conclude the game is broken. People expect randomness to look evenly spread, and they remember bad streaks far more than good ones. They also misjudge probabilities near the extremes: a 90 percent hit chance that misses twice in a row (a 1 in 100 event, which happens constantly across many players) feels like a lie.
So the goal is not mathematically pure randomness. It is randomness that matches what players think randomness looks like, while keeping long-run odds where you want them.
Seeded generators and streams
`Math.random()` in JavaScript cannot be seeded, so you cannot replay a run, share a daily challenge or reproduce a bug a player reported. Use a small seeded pseudo-random generator instead (simple, well-known ones like mulberry32 or xorshift are a few lines and fine for games; they are not for security). Give it a seed and it produces the same sequence every time.
- One stream per system. Separate generators for level layout, loot, combat and cosmetic effects, each seeded from the run seed. Otherwise, adding a particle effect that calls random once shifts every later loot roll, and the same seed produces a different run.
- Daily seeds. Seed from the date (for example, 2026-11-22 turned into a number) and everyone gets the same daily level. Our daily puzzle guide builds on this.
- Save the state. Store the generator's state in the save file. Without it, players can reload to reroll outcomes (save scumming). With it, reloading gives the same result. Our saving progress guide covers what to store.
- Show the seed. In roguelikes, showing the run seed and letting players type one in turns runs into shareable challenges and makes bug reports reproducible.
Shuffle bags: every outcome, in some order
A shuffle bag puts every possible outcome in a list, shuffles it (Fisher-Yates is the standard, correct shuffle), and deals from it until it is empty, then refills and reshuffles. Falling block puzzle games famously deal pieces this way, seven pieces to a bag, so the longest drought for any piece is twelve draws.
- Weights by copies. To make an outcome twice as common, put two copies in the bag. A bag of 10 with 7 normal enemies, 2 elites and 1 treasure goblin gives exact long-run rates and no long droughts.
- Bag size controls streakiness. A small bag is very even and somewhat predictable; a big bag feels more random. Ten to twenty items is a good range for drops and events.
- Card games are shuffle bags. A deck is a bag the player can see. That is why deckbuilders feel fair even with lots of randomness: the player knows what is left.
- Avoid repeats across refills. When a bag refills, the last item of the old bag can come first in the new one. If back-to-back repeats matter, swap the first item if it equals the last one dealt.
Pity timers and streak breakers
Pity timers guarantee a rare outcome after a number of failures. The simplest version: a rare item has a 2 percent drop chance, and after 60 kills without it, the next drop is guaranteed. A smoother version raises the chance a little after every miss and resets it on a hit, so the outcome feels natural rather than scheduled.
- Increasing chance. Start at a base value and add a fixed step after each miss: for example 5 percent, then 10, 15 and so on until it lands, then reset to 5. Tune the step so the average matches the rate you want (the step is lower than the displayed rate, because the chance climbs).
- Hard cap. Guarantee the outcome after N misses, with N around 2 to 3 times the expected number of tries. Players rarely reach it; it exists to cut off the worst tail.
- Streak breakers for bad outcomes. After two misses in a row on a high-chance attack, quietly guarantee the third. After three hits in a row on the player from a 30 percent enemy crit, block the fourth.
- Need-weighted rolls. Raise healing drop odds when the player is low, lower duplicate odds for items they already have. Players read this as luck, not as help.
If your game sells randomized items for real money, the rules are different: many app stores and some countries require published odds, and pity mechanics are often expected or required. Our web game monetization guide is the place to start, and the honest default is to show exact odds there.
Displayed odds: exact or generous?
Some well-known strategy and tactics games show a hit chance but roll something more generous underneath on easier settings, because players feel cheated by honest 85 percent misses. Others keep shown odds exact and accept the complaints. Both are defensible, as long as you choose deliberately:
- Exact odds suit competitive and multiplayer games, and anything involving money. Players can learn and trust them.
- Generous odds for the player (and never for the enemy) suit single-player story and casual games. A common trick: odds shown above 50 percent are rolled slightly higher than shown.
- Remove the number. Showing "likely" and "risky" instead of percentages avoids the problem entirely in casual games.
- Two-roll averaging. Roll twice and average for hit checks. The distribution clusters toward the middle, so high chances hit more and low chances hit less, matching intuition.
Input randomness versus output randomness
Designers distinguish randomness that happens before the player decides (a dealt hand, a generated map, the next three pieces shown) from randomness that happens after (did my attack hit?). Input randomness creates decisions and feels fair, because the player adapts to it. Output randomness can make good decisions fail, which feels bad. When randomness in your game feels unfair, try moving it earlier: show the next enemy's intent, deal the hand before the turn, preview the next piece. Our procedural generation guide is the other half of input randomness.
Bugs that randomness causes
- Modulo bias. `randomInt % 6` on a range that is not a multiple of 6 slightly favors low numbers. Use `Math.floor(random() × n)` with a float in [0, 1).
- Inclusive off-by-one. A random index of `floor(random() × length)` is correct; `round` gives the first and last items half the chance and can go out of bounds.
- Seeding with time in multiplayer. Two clients seeded from their own clocks generate different worlds. Seed from a value the server or host sends.
- Hidden consumption. UI code or a debug overlay that calls the gameplay generator changes results between builds. Use the cosmetic stream for anything not gameplay.
- Biased shuffles. Sorting with a random comparator does not shuffle evenly. Use Fisher-Yates.
A brief to paste
Make randomness in my roguelike fair and reproducible. Replace Math.random with a seeded generator (mulberry32) and split it into separate streams for map layout, loot, combat and cosmetic effects, all derived from one run seed shown on the pause screen; players can type a seed to replay a run. Daily mode seeds from the date. Store the generator state in the save so reloading does not reroll. Room types come from a shuffle bag of 12 (6 fights, 2 elites, 2 shops, 1 treasure, 1 rest), refilled when empty, never repeating the last room first. Rare relics drop at 3 percent rising by 1 percent per miss, guaranteed by 60 kills, reset on drop. Player attacks shown above 50 percent roll 5 points higher than shown; enemy attacks are exact. After two player misses in a row, the third hits. Use Fisher-Yates for all shuffles.
Frequently asked questions
What is a pity timer in games?
A rule that guarantees a rare outcome after a number of failed tries, or raises the chance after each miss. It cuts off the long unlucky streaks that pure randomness produces.
What is a shuffle bag?
A list containing every possible outcome, weighted by how many copies of each it holds, shuffled and dealt until empty, then refilled. It guarantees every outcome appears within each cycle.
Why should I use a seeded random number generator?
A seed makes the sequence reproducible, which lets you replay runs, give everyone the same daily challenge, stop players rerolling by reloading and reproduce reported bugs.
Is it cheating to make displayed odds more generous?
In single-player games, many designers consider it a fair way to match how players perceive probability. Keep odds exact in competitive games and anything involving real money.

