Pseudorandom number generation in Pokémon: Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
m (→‎In the Pokémon games: format, wording)
(31 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{{move|Pseudorandom number generation in Pokémon}}
A '''pseudorandom 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 forms of software, they must get as close to looking it 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.
A '''pseudo-random number generator''' is an electronic device or software's attempt at creating a random number. Computers are not designed to be random, and cannot yet be truly 'random' on their own. In order to generate 'random' events in games and other forms of software, they must get as close to looking it 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==
==Mechanics==
First the generator must have a seed, a number to start with. This number is usually a date and time referring to the first time 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'.
First, the generator must have a ''seed'', 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.
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.


==In Pokémon==
==In the Pokémon games==
===Linear Congruential random number generator (LCRNG)===
[[Pokémon Stadium (English)|Pokémon Stadium]] and games in [[Generation III]] and [[Generation IV]] use a 32-bit LCRNG.


Let ''Seed'' be a number between 0 and 0xFFFFFFFF or the ''Result'' of a previous call to the equation.
Below, ''seed'' is a number between 0 and 0xFFFFFFFF. If the generator has been called previously, ''seed'' is the ''result'' value from the previous call to the generator.


''Result = [(0x41C64E6D * Seed) + 0x6073]''
*Pokémon Stadium: <code>''result'' = 0x41C64E6D * ''seed'' + 0x0000303B</code>
** This equation is run several times depending on the N64's Count register, then {{wp|exclusive or|XOR}}'d with another pseudorandom value
*Pokémon Colosseum: <code>''result'' = 0x000343FD * ''seed'' + 0x00269EC3</code>
*[[Game Boy Advance|GBA]] and [[Nintendo DS|DS]] games: <code>''result'' = 0x41C64E6D * ''seed'' + 0x00006073</code>


This algorithm is used for the following:
In [[Generation III]] and [[Generation IV]], this algorithm is used for the following:
* Encrypting Pokémon data in the save file.
* Encrypting Pokémon data in the [[Save|save file]]
* Generate the [[personality value]] of a wild encountered Pokémon.
* Generating the [[personality value]] of a [[Wild Pokémon|wild encountered Pokémon]]
* Generate the [[individual values]] of a wild encountered Pokémon.
* Generating the [[individual values]] of a wild encountered Pokémon in [[Generation III]] and [[Generation IV]]
* Determining the species of a wild Pokémon.
* Determining the species of a wild Pokémon
* Determining the lottery number.
* Determining the [[Pokémon Lottery Corner]] lucky number
* Determining if an {{pkmn|Egg}} will be available at the {{pkmn|Day Care}}
 
In [[Generation V]] and [[Generation VI]], the games instead use a 64-bit LCRNG as follows:
 
<code>''result'' = 0x5D588B656C078965 * ''seed'' + 0x0000000000269EC3</code>
 
===Alternative pseudorandom number generator (ARNG)===
The [[Generation 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:


== Alternative pseudo-random number generator ==
<code>''result'' = 0x6C078965 * ''seed'' + 0x00000001</code>


The game also uses 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:
This algorithm is used for the following:
* Restrictions on Shininess for the [[Pokémon Ranger (game)|Pokémon Ranger]] {{p|Manaphy}} Egg and Type 1 [[Wonder Card]] Pokémon (currently all released with variable [[Nature]]s)
* Determining the species of a [[Pokémon outbreak|Pokémon swarm]]
* Determining the Pokémon in the [[Great Marsh]]
* Determining the Pokémon in the [[Trophy Garden]]


''Result = [(0x6C078965 * Seed) + 0x1]''
===Mersenne Twister (MTRNG)===
Found in [[Generation IV]] and later, the Mersenne 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:
This algorithm is used for the following:
* Shiny Pokémon Ranger {{p|Manaphy}} egg restriction.
* Egg PIDs in [[Generation IV]]
* Determining the species of a Pokémon swarm.
* Friendship change calculations
* Determining the Pokémon in the [[Great Marsh]].
* Sprite animations in [[Generation V]]
* Determining the Pokémon in the Trophy Garden.
* Individual values in Generation V
* [[Mystery Gift]] shininess restriction for Type 1 [[Wonder Card]] Pokémon (currently all released with variable natures).
* AI move decisions in Generation V


==RNG Abuse==
==RNG abuse==
'''RNG abuse''', also referred to as '''RNG manipulation,''' is a procedure that manipulates the pseudo-random number generator in the main series games to obtain a desired Pokémon. It is commonly used to obtain [[shiny Pokémon]] or Pokémon with high [[IV|Individual values]].
'''RNG abuse''', also referred to as '''RNG manipulation,''' is a procedure that manipulates the pseudorandom number generators in the main series games to obtain a desired Pokémon. It is commonly used to obtain [[Shiny Pokémon]], Pokémon with high [[individual values]], Pokémon with a specific set of individual values that yield a particular {{m|Hidden Power}} output (regarding [[Type]] and/or move [[Power]]), or Pokémon with certain Natures.


As the initial seed is predictable, the "random" numbers are predictable as well. {{game|Emerald}}'s initial seed is always 0. The Generation IV and V games use the [[Nintendo DS]]'s date, time, and delay between starting the game and pressing "Continue" to generate the initial seed.
In games where the initial seed (on startup) is predictable, the subsequent "random" numbers are predictable as well. {{game|Emerald}}'s initial seed is always 0. The [[Generation IV]] games use the [[Nintendo DS]]'s [[Days of the week|date]], [[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's [[personality value]] and [[IV|Individual values]] when it is encountered or received. After the initial seed is discovered, the player can control a Pokémon's characteristics with frame precise timing (frame increases by 60 frames per second in Pokémon Emerald). There are several methods used to create a Pokémon's characteristics - for instance, a bred Pokémon and a stationary Pokémon's characteristics are generated through different methods.
The random number generator is used to determine a Pokémon's [[personality value]] and individual values when it is encountered or received as an {{pkmn|Egg}} or a {{pkmn2|gift}}. 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.


There are some limitations. As a player's Trainer ID and Secret ID determine a Pokémon's shininess, shiny Pokémon generated through certain methods can only have certain Individual Values. Also, it is not possible to manipulate the nature of a Pokémon obtained through a [[Wonder Card]].
In [[Generation III]] and Generation IV, there are some limitations. As a player's [[Trainer ID|Trainer 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 to [[Wonder 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 Pokémon fandom, RNG abuse is slightly controversial. Proponents note that RNG abuse does not require a third-party device and that RNG abused Pokémon can be obtained through normal gameplay. In addition, RNG abused Pokémon have been allowed at the [[Pokémon_Organized_Play_(TCG)#Video_Game_Championships|Video Game Championships]], an official tournament. However, some players believe that RNG abuse is cheating, as the action of picking a Pokémon's characteristics is similar to using a program like Pokésav.
In the Pokémon fandom, RNG abuse is slightly controversial. Proponents note that RNG abuse does not require a third-party device and that the Pokémon obtained through RNG abuse can be obtained through normal gameplay. In addition, Pokémon obtained through RNG abuse have been used at the {{DL|Play! Pokémon|Video Game Championships}}, an official tournament. They also say that RNG abuse is very complicated, and not as simple as typing a cheat code. However, some players believe that RNG abuse is cheating, as the action of picking a Pokémon's characteristics is similar to using a [[cheating]] 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.


==See also==
==External links==
* {{wp|Pseudorandom number generator}}
* [[wp:Pseudorandom number generator|Pseudorandom number generator on Wikipedia]]
* [[wp:Mersenne twister|Mersenne Twister on Wikipedia]]
* [http://www.smogon.com/ingame/rng/emerald_rng_intro Smogon's explanation and guide on Pokémon Emerald RNG Abuse]
* [http://www.smogon.com/ingame/rng/emerald_rng_intro Smogon's explanation and guide on Pokémon Emerald RNG Abuse]
* [http://www.smogon.com/ingame/rng/dpp_rng_intro Smogon's explanation and guide on Generation IV RNG Abuse]
* [http://smogon.com/ingame/rng/dpphgss_rng_intro Smogon's explanation and guide on Generation IV RNG Abuse]
* [http://smogon.com/ingame/rng/bw_rng_intro Smogon's explanation and guide on Generation V RNG Abuse]
 
{{Project Games notice|game mechanic}}


[[Category:Game mechanics]]
[[Category:Game mechanics]]


[[de:RNG]]
[[de:Random Number Generator]]
[[fr:RNG]]
[[fr:RNG]]
[[it:Generazione di numeri pseudo-casuali in Pokémon]]
[[ja:乱数ポケモン]]
[[ja:乱数ポケモン]]
[[zh:伪随机数发生器]]

Revision as of 22:59, 18 March 2016

A pseudorandom 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 forms of software, they must get as close to looking it 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 a seed, 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.

In the Pokémon games

Linear Congruential random number generator (LCRNG)

Pokémon Stadium and games in Generation III and Generation IV use a 32-bit LCRNG.

Below, seed is a number between 0 and 0xFFFFFFFF. If the generator has been called previously, seed is the result 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, then XOR'd with another pseudorandom value
  • Pokémon Colosseum: result = 0x000343FD * seed + 0x00269EC3
  • GBA and DS games: result = 0x41C64E6D * seed + 0x00006073

In Generation III and Generation IV, this algorithm is used for the following:

In Generation V and Generation VI, the games instead use a 64-bit LCRNG as follows:

result = 0x5D588B656C078965 * seed + 0x0000000000269EC3

Alternative pseudorandom number generator (ARNG)

The Generation 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:

Mersenne Twister (MTRNG)

Found in Generation IV and later, the Mersenne 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:

  • Egg PIDs in Generation IV
  • Friendship change calculations
  • Sprite animations in Generation V
  • Individual values in Generation V
  • AI move decisions in Generation V

RNG abuse

RNG abuse, also referred to as RNG manipulation, is a procedure that manipulates the pseudorandom number generators in the main series games to obtain a desired Pokémon. It is commonly used to obtain Shiny Pokémon, Pokémon with high individual values, Pokémon with a specific set of individual values that yield a particular Hidden Power output (regarding Type and/or move Power), or Pokémon with certain Natures.

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. The Generation IV games use the Nintendo DS's date, 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's personality value and individual values when it is encountered or received as an Egg or a gift. 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.

In Generation III and Generation IV, there are some limitations. As a player's Trainer 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 to Wonder 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 Pokémon fandom, RNG abuse is slightly controversial. Proponents note that RNG abuse does not require a third-party device and that the Pokémon obtained through RNG abuse can be obtained through normal gameplay. In addition, Pokémon obtained through RNG abuse have been used at the Video Game Championships, an official tournament. They also say that RNG abuse is very complicated, and not as simple as typing a cheat code. However, some players believe that RNG abuse is cheating, as the action of picking a Pokémon's characteristics is similar to using a cheating 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

Project Games logo.png This game mechanic article is part of Project Games, a Bulbapedia project that aims to write comprehensive articles on the Pokémon games.