Random and Fairness
Random numbers can be essential to many different types of games. However, it also causes fairness concerns when playing in MiniTon tournaments. In order to address the potential imbalance caused by random numbers, the MiniTon SDK has methods to generate random numbers; the numbers returned by MiniTon are in the same sequence for each player in a match.
The MiniTon random generator ensures that each competitor in a match receives the exact sequence of random values to maintain fairness.
API Methods
This lists the most commonly used methods. View the exhaustive list here.
MiniTonCrossPlatform.Random.Value()Returns
A generated pseudo random float value
MiniTonCrossPlatform.Random.Range(float min, float max)Parameters
min The minimum float value of the range
max The maximum float value of the range
Returns
A generated pseudo random float value within the range given
The Random function
Range(float min, float max)requires the min and max value range (max-min) to be no larger thanFloat.MaxValueto prevent overflow.
MiniTonCrossPlatform.Random.Range(int min, int max)Parameters
min The minimum int value of the range
max The maximum int value of the range
Returns
An int value within the range given
The Random function
Range(int min, int max)requires the min and max value range (max-min) to be no larger thanInt.MaxValueto prevent overflow.
To provide the equivalent functionality in JavaScript for generating a pseudo-random float value using MiniTonCrossPlatform.Random.Value(), you can use the following JavaScript code:
The getRandomFloat function returns a pseudo-random float value, and you can use it in your game as needed. The code generates a float value between 0 (inclusive) and 1 (exclusive).
To provide the equivalent functionality in JavaScript for generating a pseudo-random float value within a specified range using MiniTonCrossPlatform.Random.Range(min, max), you can use the following JavaScript code:
In this JavaScript version, you should have a MiniTonCrossPlatform object initialized with a Random module. The getRandomFloatInRange function generates a pseudo-random float value within the specified range [min, max). It also includes a check to ensure that the range does not exceed the maximum allowed value to prevent overflow, as mentioned in your documentation.
You can customize the min and max parameters according to your desired range, and the randomValueInRange variable will hold the generated random float value within that range.
To provide the equivalent functionality in JavaScript for generating a pseudo-random integer value within a specified range using MiniTonCrossPlatform.Random.Range(min, max) with integer parameters, you can use the following JavaScript code:
In this JavaScript version, you should have a MiniTonCrossPlatform object initialized with a Random module. The getRandomIntInRange function generates a pseudo-random integer value within the specified range [min, max]. It includes a check to ensure that the range does not exceed the maximum allowed safe integer value to prevent overflow, as mentioned in your documentation.
You can customize the min and max parameters according to your desired integer range, and the randomIntInRange variable will hold the generated random integer value within that range.
Considerations
Please be aware that use of the MiniTon random methods does not guarantee that all players will have an identical game experience. These methods can only ensure that players get the same sequence of random numbers. Over time, the playerβs decisions may diverge and the same random number will not be used in the same place.There may be places where the random decision is trivial to the outcome of the game, or purely aesthetic; in that case we recommend you do not use the MiniTon random methods to reduce the chances of making a different number of calls between players.
Ensure Players Cannot Obtain Advantages from Outside the Game
With the potential for real money to be awarded to one player or another, be certain that players wonβt have any edge based on factors outside the tournament they are playing. Examples of this include items obtained from in-app purchases or bonuses gained from playing in single-player mode. This is highly specific to each individual game, but if there are any ways for players to obtain in-game bonuses these should be disabled when playing with MiniTon.
Last updated
Was this helpful?