Pseudorandom number generation
Apseudorandom number generator is an electronic device or software's attempt at creating a random number. Just as rolling a die is not random (being determined by factors such as force and angle of the throw, as well as friction), computers cannot be truly random. In order to generate "random" events in games and other software, they must get as close to seeming random as they can. There are limitless ways of accomplishing this. The degree of apparent randomness depends on the ability to predict the next result of the algorithm.
Mechanics
First, the generator must have aseed, a number to start with. This number is usually a date and time referring to the first time that the algorithm is called during the usage of the device or the software's active session. Seeds are also occasionally derived from user input, as it is highly improbable to do the exact same thing more than once, making it appear 'random'.
This number is put through a complex algorithm, and the result is formatted according to the needed context. The raw result then becomes the seed for any subsequent uses of the random generator. Therefore, the nature of the generator is a recursive algorithm.
Algorithms
Linear Congruential random number generator (LCRNG)
Pokémon Stadium,Pokémon Stadium 2, theGeneration III andGeneration IV core series games, andPokémon Colosseum use a 32-bitlinear congruential generator.
Below,seed is a number between 0 and 0xFFFFFFFF. If the generator has been called previously,seed is theresult value from the previous call to the generator.
- Pokémon Stadium:
result = 0x41C64E6D ×seed + 0x0000303B- This equation is run several times depending on the N64's Count register, thenXOR'd with another pseudorandom value
- Pokémon Stadium 2[1]:
result = 0x0019660D ×seed + 0x3C6EF35F - Pokémon Colosseum:
result = 0x000343FD ×seed + 0x00269EC3 - GBA andDS games:
result = 0x41C64E6D ×seed + 0x00006073 - Pokémon Machine v2 distributions:
result = 0x41C64E6D ×seed + 0x00003039
InGeneration III andGeneration IV, this algorithm is used for the following:
- Encrypting Pokémon data in thesave file
- Generating thepersonality value of awild Pokémon
- Generating theindividual values of a wild encountered Pokémon inGeneration III andGeneration IV
- Determining the species of a wild Pokémon
- Determining thePokémon Lottery Corner lucky number
- Determining if anEgg will be available at thePokémon Day Care
InGeneration V andGeneration VI, the games instead use a 64-bit LCRNG as follows:
result = 0x5D588B656C078965 ×seed + 0x0000000000269EC3
Alternative pseudorandom number generator (ARNG)
TheGeneration IV games also use a different algorithm to alternate, reroll, or modify a previously randomly generated value. The algorithm works in the same nature; however, the equation changes to:
result = 0x6C078965 × seed + 0x00000001
This algorithm is used for the following:
- Restrictions on Shininess for thePokémon RangerManaphy Egg, Type 1Wonder Card Pokémon, andMy Pokémon Ranch'sMew andPhione (currently all released with variableNatures)
- Determining the species of amass outbreak
- Determining the Pokémon in theGreat Marsh
- Determining the Pokémon in theTrophy Garden
Mersenne Twister (MTRNG)
Found inGeneration IV and later, theMersenne Twister is another type of random number generator that produces 624 random numbers at once. These random numbers are then stored and used when needed. When all 624 numbers are used, another set is generated.
This algorithm is used for the following:
- TID and SID inGeneration IV
- Egg PIDs in Generation IV
- Friendship change calculations
- Sprite animations inGeneration V
- Individual values in Generation V
- AI move decisions in Generation V
Xoroshiro
Found inGeneration VIII,Xoroshiro128+ is another type of random number generator used, however this is not the sole form of RNG used, as it is used in tandem withCSPRNG.
The following is a non-comprehensive list of instances where this algorithm appears:
- RNG advancements inPokémon Sword and Shield
- Symbol encounters,hidden encounters,fishing, andpersonality value andstat generation ofwanderers inPokémon Sword and Shield[2]
- Pokémon Den andDynamax Adventure generation inPokémon Sword and Shield[3]
- PartialEgg generation in Generation VIII[4]
- The spawning algorithm inPokémon: Let's Go, Pikachu! and Let's Go, Eevee![5]
- AI move decisions inPokémon Brilliant Diamond and Shining Pearl
Xorshift
Found inGeneration VIII,Xorshift is another type of random number generator used, however this is not the sole form of RNG used, as it is used in tandem withCSPRNG.
The following is a non-comprehensive list of instances where this algorithm appears:
- Trainer ID and Secret ID generation inPokémon Brilliant Diamond and Shining Pearl
- Pokémon generation inPokémon Brilliant Diamond and Shining Pearl
Cryptographically Secure (CSPRNG or CPRNG)
Found inGeneration VIII,Cryptographically secure RNG is another type of random number generator used, however this is not the sole form of RNG used, as it is used in tandem withXorshift orXoroshiro.
Notably, this type of random number generator is not possible to RNG abuse due to its nature.[6]
The following is a non-comprehensive list of instances where this algorithm appears:
- Initial seeding inPokémon: Let's Go, Pikachu! and Let's Go, Eevee! andGeneration VIII
- Trainer ID and Secret ID generation inPokémon: Let's Go, Pikachu! and Let's Go, Eevee!,Pokémon Sword and Shield, andPokémon Legends: Arceus
- Personality value generation inPokémon: Let's Go, Pikachu! and Let's Go, Eevee!
- Non-overworldLegendaries,Curry, and scripted encounters inPokémon Sword and Shield
- Egg seeding and individual rolls in Generation VIII[7]
RNG abuse
RNG abuse, also referred to asRNG manipulation, is a procedure that manipulates the pseudorandom number generators in thecore series games to obtain a desiredPokémon. It is commonly used to obtainShiny Pokémon, Pokémon with highindividual values, Pokémon with a specific set of individual values that yield a particularHidden Power output (regardingtype or movepower), or Pokémon with certainNatures.
In games where the initial seed (on startup) is predictable, the subsequent "random" numbers are predictable as well.Pokémon Emerald's initial seed is always 0. TheGeneration IV games use theNintendo DS'sdate,time, and delay between starting the game and pressing "Continue" to generate the initial seed.Generation V games use the Nintendo DS's date, time, keys currently pressed, and other entropy data to create a seed moments before the Nintendo logo appears.
The random number generator is used to determine a Pokémon'spersonality value and individual values when it is encountered or received as anEgg or agift. By searching for initial seeds that satisfy the characteristics required, the player can then hit the target seed and advance 'frames' to receive their target characteristics. There are several methods used to influence a Pokémon's characteristics — for instance, a bred Pokémon and a stationary wild Pokémon's characteristics are generated through different methods.
InGeneration III and Generation IV, there are some limitations. As a player'sTrainer ID and Secret ID numbers determine a Pokémon's shininess, Shiny Pokémon generated through certain methods can only have certain individual values. Due toWonder Card gifts using a timer register to create personality values, it is not possible to manipulate a gift's Nature. In Generation V, this is no longer the case as the individual values and personality values are determined from two different RNGs.
In the fandom
In thePokémon fandom, RNG abuse is slightly controversial. RNG abuse largely does not require third-party devices or custom firmware, and the Pokémon obtained through RNG abuse can be obtained through normal gameplay, with onlyLegal values. In addition, Pokémon obtained through RNG abuse have been permitted at theVideo Game Championships, as the rules do not explicitly disallow Pokémon obtained in this manner, with some participants reporting that event staff permitted their use even with admission of having performed RNG abuse.[8] RNG abuse also requires a degree of preparation, effort, and skill, as the player is required to learn and use various tools and programs to calculate how to obtain a Pokémon with specific attributes, whereas using a cheat device or editing software can grant a Pokémon with specific attributes nearly instantly, and unlike RNG abuse, would permitIllegal values. RNG abuse is also widely used in thespeedrunning community in order to increase consistency and avoid wild encounters.
However, some players believe that RNG abuse is cheating, as the action of picking a Pokémon's characteristics directly is similar to using a cheat device. Opponents of RNG abuse claim that it gives those who can RNG an unfair advantage, however the proponents say that with RNG everyone can have the best stats, and therefore no one will have an unfair advantage by catching a Pokémon that happens to be better.
External links
- Pseudorandom number generator on Wikipedia
- Mersenne Twister on Wikipedia
- Smogon's explanation and guide on Pokémon Emerald RNG Abuse
- Smogon's explanation and guide on Generation IV RNG Abuse
- Smogon's explanation and guide on Generation V RNG Abuse
References
| This game mechanic article is part ofProject Games, aBulbapedia project that aims to write comprehensive articles on thePokémon games. |
