Open main menu

Bulbapedia β


Pseudorandom number generation in Pokémon

139 bytes added, 22:59, 18 March 2016
In the Pokémon games: format, wording
==In the Pokémon games==
===Linear Congruential random number generator (LCRNG)===
In [[Pokémon Stadium (English)|Pokémon Stadium]], and games in [[Generation III]] and [[Generation IV]], the games use a 32 -bit LCRNG.
LetBelow, ''Seedseed'' beis a number between 0 and 0xFFFFFFFF. orIf the generator has been called previously, ''Resultseed'' ofis athe ''result'' value from the previous call to the equationgenerator.
*Pokémon Stadium: <code>''result''Result = [(0x41C64E6D * Seed) + 0x303B]'' {{tt|*|Called several times depending on the N64seed's Count register, then xor'd with another pseudo-random+ value}}0x0000303B</code>
*Pokémon* Colosseum:This ''Resultequation =is [(0x343FDrun *several Seed)times +depending 0x269EC3]on the N64's Count register, then {{wp|exclusive or|XOR}}'d with another pseudorandom value
*[[GamePokémon Boy Advance|GBA]] and [[Nintendo DS|DS]] gamesColosseum: <code>''result''Result = [(0x41C64E6D0x000343FD * Seed)''seed'' + 0x6073]''0x00269EC3</code>
*[[Game Boy Advance|GBA]] and [[Nintendo DS|DS]] games: <code>''result'' = 0x41C64E6D * ''seed'' + 0x00006073</code>
In [[Generation III]] and [[Generation IV]], this algorithm is used for the following:
* Encrypting Pokémon data in the [[Save|save file]].
* GenerateGenerating the [[personality value]] of a [[Wild Pokémon|wild encountered Pokémon]].
* GenerateGenerating 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 [[Pokémon Lottery Corner]] lucky number.
* Determining if an egg{{pkmn|Egg}} will be available at the [[Pokémon {{pkmn|Day Care]].}}
In [[Generation V]] and [[Generation VI]], the games instead use a 64 -bit LCRNG as follows:
<code>''result''Result = [(0x5D588B656C078965 * Seed)''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:
<code>''result''Result = [(0x6C078965 * Seed)''seed'' + 0×1]''0x00000001</code>
This algorithm is used for the following:
* ShinyRestrictions on Shininess for the [[Pokémon Ranger (game)|Pokémon Ranger]] {{p|Manaphy}} {{pkmn|Egg}} restriction.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]].
* [[Mystery Gift]] shininess restriction for Type 1 [[Wonder Card]] Pokémon (currently all released with variable [[Nature]]s).
===Mersenne Twister (MTRNG)===
This algorithm is used for the following:
* Egg PIDs in [[Generation IV]].
* Friendship Changechange Calculations.calculations
* Sprite Animationsanimations in [[Generation V]].
* Individual Valuesvalues in Generation V.
* AI Movemove decisions in Generation V.
==RNG abuse==