# Difference between revisions of "Pseudorandom number generation in Pokémon"

A pseudo-random number generator is an electronic device or software's attempt at creating a sufficiently random number. There are limitless ways of accomplishing this. The degree of sufficient 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 & time referring to the first time the algorithm is called during the usage of the device or the software's active session.

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

Let Seed be a number between 0 and 0xFFFFFFFF or the Result of a previous call to the equation.

Result = [(0x41C64E6D * Seed) + 0x6073]

This algorithm is used for the following:

• Encrypting Pokémon data in the save file.
• Generate the personality value of a wild encountered Pokémon.
• Generate the individual values of a wild encountered Pokémon.
• Determining the species of a wild Pokémon.
• Determining the lottery number.

## Alternative pseudo-random number generator

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:

Result = [(0x6C078965 * Seed) + 0x1]

This algorithm is used for the following:

• Shiny Pokémon Ranger Manaphy egg restriction.
• Determining the species of a Pokémon swarm.
• Determining the Pokémon in the Safari Zone.
• Determining the Pokémon in the Trophy Garden.
• Mystery Gift shiny restriction for Type 1 Wondercard Pokémon (currently all released with variable natures).