<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg" -->

---
title: How to control randomness in your game | daily.dev
description: Explains why pure random number generation feels unfair to players even when the math is correct, since stateless rolls allow long unlucky streaks. Proposes a...
canonical: https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to control randomness in your game | daily.dev
og:description: Explains why pure random number generation feels unfair to players even when the math is correct, since stateless rolls allow long unlucky streaks. Proposes a...
og:url: https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg
og:image: https://api.daily.dev/og/posts/nLuMY5zBG.png
og:image:alt: How to control randomness in your game
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to control randomness in your game

**[YouTube](https://daily.dev/sources/youtube)** · 2 min read · 1 upvotes · 0 comments

## Summary

Explains why pure random number generation feels unfair to players even when the math is correct, since stateless rolls allow long unlucky streaks. Proposes a 'marble bag' technique - essentially drawing without replacement, like a deck of cards - to give randomness memory and make outcomes feel fairer. Shows how nested marble bags were used in a word game jam project to control letter distribution, and shares a templated C# class for Unity projects implementing the pattern.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=2anY9ICA-Pg>

## Questions this post answers

### How do I make crit chance or loot drops in my game feel less unfair without changing the actual odds?

Use a stateful sampling method often called a marble bag instead of pure random rolls. Fill a virtual bag with marbles representing outcomes in the right ratio (two red, six blue for a 25% crit chance), draw one without replacement each time an outcome is needed, and refill the bag once it empties. This prevents long unlucky streaks because the odds shift as marbles are removed, mimicking how players intuitively expect randomness to self-correct over short stretches.

_Developers tuning drop rates or crit chances can find implementation patterns and code examples on daily.dev._

### What is the mathematical problem with using pure random rolls for a 25% crit chance in a game?

With a true 25% independent chance per swing, there is a 31.6% probability of four consecutive swings without a crit, and roughly a 10% chance of eight swings in a row without one. The math is statistically correct, but because each roll is stateless nothing prevents long bad streaks, which players perceive as broken or unfair even though the underlying probability is accurate.

_Anyone balancing combat systems can weigh probability trade-offs like this by following game design discussions on daily.dev._

## Similar posts on daily.dev

- [Random rewards enrich classic game-theory insights](https://daily.dev/posts/random-rewards-enrich-classic-game-theory-insights-zudmqcxef) · Ars Technica · 1 upvotes · 0 comments
- [The little Random that could](https://daily.dev/posts/the-little-random-that-could-a4hxu0o5m) · RUBYLAND · 0 upvotes · 0 comments
- [Reversing Factorio's RNG](https://daily.dev/posts/reversing-factorio-s-rng-wq3cvdmbf) · Lobsters · 0 upvotes · 0 comments
- [How to Implement Randomization with the Python Random Module](https://daily.dev/posts/how-to-implement-randomization-with-the-python-random-module-b9uussinr) · Towards Data Science · 0 upvotes · 0 comments
- [The Random Numbers in Your Simulation Are Not Random. So Why Does Monte Carlo Work?](https://daily.dev/posts/the-random-numbers-in-your-simulation-are-not-random-so-why-does-monte-carlo-work--gd3fy0xyq) · Medium · 0 upvotes · 0 comments

---

Tags: [#game-development](https://daily.dev/tags/game-development), [#c#](https://daily.dev/tags/c#), [#game-design](https://daily.dev/tags/game-design), [#unity](https://daily.dev/tags/unity)

[View this post on daily.dev](https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to control randomness in your game","url":"https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg"},"datePublished":"2026-08-17T20:50:08.790Z","dateModified":"2026-09-14T08:45:28.246Z","description":"Explains why pure random number generation feels unfair to players even when the math is correct, since stateless rolls allow long unlucky streaks. Proposes a...","image":"https://i.ytimg.com/vi/2anY9ICA-Pg/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/2anY9ICA-Pg/sddefault.jpg","isAccessibleForFree":true,"articleSection":"YouTube","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"YouTube","logo":"https://media.daily.dev/image/upload/s--W5zMumpP--/f_auto/v1725350181/logos/youtube","url":"https://daily.dev/sources/youtube"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"game-development,c#,game-design,unity","timeRequired":"PT2M","video":{"@type":"VideoObject","name":"How to control randomness in your game","description":"Explains why pure random number generation feels unfair to players even when the math is correct, since stateless rolls allow long unlucky streaks. Proposes a...","thumbnailUrl":"https://i.ytimg.com/vi/2anY9ICA-Pg/sddefault.jpg","uploadDate":"2026-08-17T20:50:08.790Z","duration":"PT2M","url":"https://api.daily.dev/r/nLuMY5zBG","embedUrl":"https://www.youtube.com/embed/2anY9ICA-Pg"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"YouTube","item":"https://daily.dev/sources/youtube"},{"@type":"ListItem","position":3,"name":"How to control randomness in your game"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-control-randomness-in-your-game-nlumy5zbg#faq","mainEntity":[{"@type":"Question","name":"How do I make crit chance or loot drops in my game feel less unfair without changing the actual odds?","acceptedAnswer":{"@type":"Answer","text":"Use a stateful sampling method often called a marble bag instead of pure random rolls. Fill a virtual bag with marbles representing outcomes in the right ratio (two red, six blue for a 25% crit chance), draw one without replacement each time an outcome is needed, and refill the bag once it empties. This prevents long unlucky streaks because the odds shift as marbles are removed, mimicking how players intuitively expect randomness to self-correct over short stretches. Developers tuning drop rates or crit chances can find implementation patterns and code examples on daily.dev."}},{"@type":"Question","name":"What is the mathematical problem with using pure random rolls for a 25% crit chance in a game?","acceptedAnswer":{"@type":"Answer","text":"With a true 25% independent chance per swing, there is a 31.6% probability of four consecutive swings without a crit, and roughly a 10% chance of eight swings in a row without one. The math is statistically correct, but because each roll is stateless nothing prevents long bad streaks, which players perceive as broken or unfair even though the underlying probability is accurate. Anyone balancing combat systems can weigh probability trade-offs like this by following game design discussions on daily.dev."}}]}
```

