Reimplement Random Number Generation (RNG) for Fairness

By now you’ve finished the core Skillz implementation and all the major components are in place to give your game multiplayer gameplay capabilities. It’s time to make sure your players’ games are fair and everyone is on a level playing field.

Note that not every game will require this step — only games in which chance (or external, non-game factors) can affect a match’s outcome will need to establish fairness. In most games that have chance, chance plays a role in initial setup (such as the arrangement of pieces at the start of a match, or the order that cards are arranged in a shuffled deck). For this type of game it is important that the random numbers generated for both opponents in the same match follow the same random, but identicalsequence. Toward this end, the Skillz SDK provides a few, high-quality random number generation routines that your game must use whenever the outcome of a match can be affected by an element of chance.


Step 1: Implementing consistent random number generation

Many games of skill also have some element of chance. For mobile games, chance is determined by computer-generated random numbers. And it is these random numbers that raise fairness concerns for each player participating in a match. So, in order to ensure that random numbers do not unduly affect the outcome of the match, each player in a Skillz match must receive the same sequence of randomly-generated numbers as the other. The Skillz API offers several routines that will do this: generate the same random sequence for a given match. The most commonly used method is getRandomNumberWIthMin:andMax:.

This method will return a random integer uniformly-distributed between min (inclusive) and max (exclusive) The maximum range that can be requested range from 0 to 2,147,483,647. Here is an example of calling this method to return a randomly-selected number from 0 up to – and including – 100).

if ([[Skillz skillzInstance] tournamentIsInProgress]) {
    return [Skillz getRandomNumberWithMin:0 andMax:101];
} else {
    return arc4random_uniform(101);

Note: you should never use modulo arithmetic (the ‘%’ operator) to generate a range of random numbers. Numbers generated in this way may show modulo bias and are therefore not all equally likely to be generated.

Please be aware that callinggetRandomNumberWithMin:andMax: (or one of the other Skillz SDK’s random number routines), may not - nor does it have to - ensure that all players in a match will have an identical experience. The players’ differing decisions made during the game may easily cause their games to diverge - which is expected and not in any way unfair. Nevertheless, it should be the case that (in theory) if both players in a match behaved identically (made the same choices at the same speed) - then the match would end in a tie. So as long as your game an make that claim (by using the Skillz API’s random number routines), then your game can be called fair.

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 getRandomNumberWithMin:andMax:. Applying getRandomNumberWithMin:andMax:conservatively will help avoid introducing fairness problems in your game.


Step 2: Ensure players cannot obtain advantages from outside the game

With the potential for real money to be awarded to one player or another in a Skillz match, it must always be the case that that neither player has any advantage over the another - if that advantage is based on something other than skill. In other words, it should never be possible for one player to gain an advantage from some external factor: such as making an in-app purchase, or acquiring new powers based on number of games played, and so forth. Examples of unfair advantages are highly game-specific, so it is not possible to enumerate them all. Nonetheless the rule is simple: if one player has established such an advantage over another in a Skillz match, then this advantage must be removed and the playing field made even throughout the match.


Step 3: Certify that you've tested for Fairness in your game.

Using our Fairness tool you can certify that you've tested our Fairness (RNG) algorithm in your game. You'll be asked to upload some screenshots of one match from the perspective of both players, where you make the exact same moves for each player.


If Skillz Fairness has been properly implemented in your game, the screenshots should match as both players will have received the same sequence of events in their gameplay. If your game does not employ RNG, just take a screenshot at the beginning of each match and upload it to certify that your game is fair.

When you've tested fairness in your game, check the "do your screenshots match" checkbox, and then click the verify button to confirm that your game is fair.



Next steps

Next, it’s time to learn how you can enable Single Sign On for your game.