Skip to main content
Back to home

Overview of our RNG

This section will explain how we generate random numbers.

Seeds

The first step in our RNG process is creating the game seed. A seed is a starting point that determines the generated random data. A seed will look something along the lines of this:

F4383F88496C4640F1030FBBDBF133BC55A1EFFF040F79670D9D86A72805F772CFBC68454BA000C4C418D503169525A1855CA177D22ABCD0C3E73CE650EAF249,0,20394

A seed consists of 3 parts: a 64 character hex string, a counter, and a random integer. The 64 character hex and random integer (20394) are generated once at the start of a game session. The counter (0) starts at 0 and every time a seed is used up, the counter goes up by one. A seed can be used to generate 8 numbers.

How do we determine your random numbers

The seed is then passed through as the input into a cryptographic hashing function called HMAC_SHA256. In HMAC_SHA256 there is also a key. This key is hidden from users to prevent cheating and is not included in the seed but is required for the SHA function. Passing the seed through this function will produce another hex known as a hash that looks something like this:

9c64b2aa2f13454be42a652338fd5a8afece592c7d4f4933eef34f923b4552f0

Implementation

Now that we have generated the hash, we can convert this hash into random numbers. The first step is we split the hash into 8 different groups. Each group is used to generate 1 random number. Groups for this hash look like this:

9c64b2aa 2f13454b e42a6523 38fd5a8a fece592c 7d4f4933 eef34f92 3b4552f0

Then we take these groups and convert them into bytes. The first group (9c 64 b2 aa) to bytes is (156, 100, 178, 170). We then use these 4 bytes to create a float between 0 and 1. The formula to create the float looks like this:

(156 / (256 ^ 1)) = 0.609375000000 +

(100 / (256 ^ 2)) = 0.001525878906 +

(178 / (256 ^ 3)) = 0.000010609627 +

(170 / (256 ^ 4)) = 0.000000039581 =

0.610911528114

Now that we have our random float we then multiply it by X. X is equal to the number of possible outcomes for a specific game. In a game using a deck of cards, X would equal 52 because there are 52 cards in a deck. Let's assume these calculations are for a game with a deck of cards. We would take our float and multiply it by X:

0.610911528114 * 52 = 31.767399461940

Depending on the game, sometimes the final result will be 31.767399461940 and that will be your random number and the next steps won't apply. In the case of other games like this example with cards, we then have to truncate the float to get an integer, so 31.767399461940 gets truncated to just 31.

Next we take the truncated number and match it up with an element inside an array. This array contains all the cards in a deck. In this example, 31 would line up to Heart_6 and that would be your random card. In a different example like the game roulette we truncate the number and the ball would land on 31 (this is just an example — in the game we do not multiply by 52 for roulette).

Our array of cards looks like this:

["Club_Ace", "Club_2", "Club_3", "Club_4", "Club_5", "Club_6", "Club_7", "Club_8", "Club_9", "Club_10", "Club_Jack", "Club_Queen", "Club_King", "Diamond_Ace", "Diamond_2", "Diamond_3", "Diamond_4", "Diamond_5", "Diamond_6", "Diamond_7", "Diamond_8", "Diamond_9", "Diamond_10", "Diamond_Jack", "Diamond_Queen", "Diamond_King", "Heart_Ace", "Heart_2", "Heart_3", "Heart_4", "Heart_5", "Heart_6", "Heart_7", "Heart_8", "Heart_9", "Heart_10", "Heart_Jack", "Heart_Queen", "Heart_King", "Spade_Ace", "Spade_2", "Spade_3", "Spade_4", "Spade_5", "Spade_6", "Spade_7", "Spade_8", "Spade_9", "Spade_10", "Spade_Jack", "Spade_Queen", "Spade_King"]

That is how we generate random numbers.

Rare Incidents

Most table games have a set deck of cards (1 deck, 2 decks, 8 decks...). In order to make sure that when playing our games simulate the proper number of decks, sometimes you will notice when looking at a seed that a card is red. When a card is shown to be red in the generated seed, that card does not get used in the game and instead the next card is used in the seed. This is done to simulate playing with X amount of decks.

In Action

In this section you can test out how our RNG works (the outcomes produced here may vary from outcomes produced in the game in order to protect our key and to prevent cheating). Input anything you want into the seed section — this can be names, numbers, or game seeds.

In the multiplier section, enter any number. Use the number 52 for a deck of cards, but you can input anything, for example 37 for a roulette table.

The output will show you what random number is generated, how, and what card it points to (when using numbers below or above 52, there is no pointed card).

When you input the number 52, you will notice another textbox appears. This textbox is used for determining how many decks of cards you want to use. This does not affect the cards generated, however it affects which cards turn red (don't get used) — you can try seed "seed99" with 2 decks of cards and seed "test205" with 2 decks of cards to understand how this works.