top of page
  • Writer's pictureMykhailo Khadzhynov

Random Utils

What is most important thing in video games? I bet, it`s a feeling of live. Game is not static, as the book. Game never repeats exactly, like movie. Every your gameplay session is different and unique.

It happens mostly because of two reasons: different player behaviour, and randomness.

It`s hard to overvalue randomness in our games. Developing different gameplays, it often happens that default Random tool, provided by unity, not enough.

For example, developing the roulette game, it was really annoying to see the ball, stopped on a same number three, four, or even five times at row. From statictics point, it`s normal: 1/37 is not so small probability, and we should understand: things, that already happen, does not influence the chance of next happenings.

It means, in roulette, every spin has 1/37 probability for EVERY number, repetitions arent less likely than any other numbers.

But most of gamblers does not understand it! And if they see three zero at row on a real roulette, they can say: "It`s a miracle!". But if they see it in a computer simulation, they`ll think "it`s a shity computer simulation".

Handling such cases time to time, I made a set of tools, which I can effectively reuse. Then I decided to share these tools with a community.

So, please meet: Random Utils

There are two tools - Randomizer and Weighted List (ugh, sounds like a band name).

Randomizer allows you to do two simple things:

- select array index randomly, but without repetitions;

- select array index multiple times, keeping it flat-distributed.

Flat distribution - is when different things happens with the same probability. Randomizer limits breaks the rule, when new choices are not affected by previous. For example, if we selecting from 6 items, and first time we selected item #2, we cant get it again, until all other items will be selected too.

Weighted List is super useful, when you need to select from list of game objects. It`s a usual list, but you can set a weight - probability - for every item.

Watch demo, subscribe channel, and read additional documentation on github

13 views0 comments

Recent Posts

See All


bottom of page