Show / Hide Table of Contents

    Interface IRandomService

    This IService manages generation of random values. This service's functionality could be overriden so that the seeds and/or random values are generated server-side.

    Namespace: IdleKit.Gameplay
    Assembly: cs.temp.dll.dll
    Syntax
    public interface IRandomService : IService

    Methods

    GetRandomDouble()

    Returns a random floating-point number greater than or equal to 0.0 and less than double.maxValue.

    Declaration
    double GetRandomDouble()
    Returns
    Type Description
    Double

    GetRandomDouble(Double, Double)

    Returns a random double that is within the specified range, inclusive of min and exclusive of max.

    Declaration
    double GetRandomDouble(double min, double max)
    Parameters
    Type Name Description
    Double min
    Double max
    Returns
    Type Description
    Double
    Remarks

    See GetRandomDouble(Int32) for limitations.

    GetRandomDouble(Double, Double, Int32)

    Returns a random double that is within the specified range, inclusive of min and exclusive of max while providing an integer random seed.

    Declaration
    double GetRandomDouble(double min, double max, int seed)
    Parameters
    Type Name Description
    Double min
    Double max
    Int32 seed
    Returns
    Type Description
    Double

    GetRandomDouble(Int32)

    Returns a random floating-point number greater than or equal to 0.0 and less than double.maxValue while providing an integer random seed..

    Declaration
    double GetRandomDouble(int seed)
    Parameters
    Type Name Description
    Int32 seed
    Returns
    Type Description
    Double
    Remarks

    The default implementation in IdleKit uses NextDouble(), which does not provide a full range of double values nor an even distribution. See https://docs.microsoft.com/en-us/dotnet/api/system.random?view=netframework-4.8#retrieve-floating-point-values-in-a-specified-range for more details. Please override this method if you wish for a truly even distribution or truncate the number of decimal places.

    GetRandomInt()

    Returns a non-negative random integer.

    Declaration
    int GetRandomInt()
    Returns
    Type Description
    Int32

    GetRandomInt(Int32)

    Returns a non-negative random integer while providing an integer random seed.

    Declaration
    int GetRandomInt(int seed)
    Parameters
    Type Name Description
    Int32 seed
    Returns
    Type Description
    Int32

    GetRandomInt(Int32, Int32)

    Returns a random integer that is within the specified range, inclusive of min and exclusive of max.

    Declaration
    int GetRandomInt(int min, int max)
    Parameters
    Type Name Description
    Int32 min
    Int32 max
    Returns
    Type Description
    Int32

    GetRandomInt(Int32, Int32, Int32)

    Returns a random integer that is within the specified range, inclusive of min and exclusive of max while providing an integer random seed.

    Declaration
    int GetRandomInt(int min, int max, int seed)
    Parameters
    Type Name Description
    Int32 min
    Int32 max
    Int32 seed
    Returns
    Type Description
    Int32

    GetRandomSeed()

    Returns a non-negative random integer for use as a seed.

    Declaration
    int GetRandomSeed()
    Returns
    Type Description
    Int32
    Remarks

    This function can be overriden to generate a seed value from the backend instead. This function is not meant to be called to return random integers in quick succession. In the default implementation of IdleKit, new Random objects created within a short time frame could use the same default seed, which returns the same integer.

    GetRandomWeightedElement<TRandomWeighted>(TRandomWeighted[])

    Returns a random element from the based on their weights.

    Declaration
    TRandomWeighted GetRandomWeightedElement<TRandomWeighted>(TRandomWeighted[] collection)
        where TRandomWeighted : class, IRandomWeighted
    Parameters
    Type Name Description
    TRandomWeighted[] collection
    Returns
    Type Description
    TRandomWeighted
    Type Parameters
    Name Description
    TRandomWeighted

    GetRandomWeightedElement<TRandomWeighted>(TRandomWeighted[], Int32)

    Returns a random element from the based on their weights while providing an integer random seed..

    Declaration
    TRandomWeighted GetRandomWeightedElement<TRandomWeighted>(TRandomWeighted[] collection, int seed)
        where TRandomWeighted : class, IRandomWeighted
    Parameters
    Type Name Description
    TRandomWeighted[] collection
    Int32 seed
    Returns
    Type Description
    TRandomWeighted
    Type Parameters
    Name Description
    TRandomWeighted

    InitializeRandom(Int32)

    Initialize a new Random object used to generate random values while providing an integer random seed.

    Declaration
    void InitializeRandom(int seed)
    Parameters
    Type Name Description
    Int32 seed
    Back to top Copyright © 2020 East Side Games Inc.