arrow_back
logo
search
SupportlaunchAPI
menulaunchSign In
close
OverviewConceptsAdmin PanelCloudAPICompliance
Overview
Get StartedAuthorizationMessagingJackpotsMultiplayerGame Client InterfaceErrors Handle
Get StartedAuthorizationGame SessionMessagingBettings and WinningsRandom Numbers GeneratorJackpotsMultiplayerTesting
Overview
Overview
Using the client libraryImplementing an integrationDeploying an integration
Replying to a gamePending Winnings
.NET CoreGoJavaNodeJsPHPPythonRuby
OverviewOverwriting jackpots
launchAPISupport
launchSign In

Random Numbers Generator

Overview

Random Number Generator (RNG) is a crucial component of online casino games and many other digital applications that require randomness. An RNG is a software algorithm designed to generate a sequence of numbers or outcomes that appear to be random and unpredictable.

Get Random Value

For get any random value, you can use any of this methods

  • Get random integer number
    var random = await _fireball.Random.GetRandomInt(minInt, maxInt);
  • Get random float (double) number
    var random = await _fireball.Random.GetRandomDouble(minDouble, maxDouble);
  • Get random boolean
    var random = await _fireball.Random.GetRandomBool();

Helper methods

Additionally, you can randomly shuffle any list by using:

    // create list of any type
    var list = new List<string>()
    {
        "one", "two", "three"
    };

    // number of shuffle iterations
    int iterations = 5;

    // randomlly shuffle list
    await _fireball.Random.Shuffle(list, iterations);

or get random element index from weighted array:

    public class ElementData
    {
        public string Id;
        public float Chance;

        public ElementData(string id, float chance)
        {
            Id = id;
            Chance = chance;
        }
    }
    ....

    // game data object example
    var elements = new List<ElementData>()
    {
        new ElementData("ace", 0.1f ),
        new ElementData("king", 0.2f ),
        new ElementData("queen", 0.3f ),
        new ElementData("jack", 0.4f ),
    };

    // select weights list from game data
    var weigths = elements.Select(w => (double)w.Chance).ToList();

    // randomlly select weghted element from list
    int index = await _fireball.Random.GetRandomIndexFromWeightsArray(weigths);


    // result
    var random = elements[index];
Copyright © 2020-. All rights reserved.v1.0.8