Check out http://www.smogon.com/dp/articles/pid_iv_creation for the version on the website. The applet for PID generation using the IVs is available here. Part 2 is in http://www.smogon.com/forums/showthread.php?t=45230. The Process of PID and IV Creation of Non-Bred Pokemon 0. Credits Before I even start, I need to give credit to loadingNOW (a.k.a. pika) and yamipoli for providing me with invaluable information regarding this topic. 1. Preliminaries We start by providing preliminary information, without which the reader will have a very hard time understanding this article. 1.1 The Binary System In a computer, numbers are not stored normally, but in a format called binary. The numbers we normally use are said to be in the decimal system. Every number in the decimal system is written as a series of digits, each of which can be one of the following ten: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. In the binary system, the same thing is true, but there are only two possible digits: 0 and 1. Each of these binary digits is called a bit (short for binary digit). For example, the binary number 10001110 has 8 bits. The Game Boy Advance and Nintendo DS systems, on which the Pokemon games Ruby, Sapphire, Emerald, Fire Red, Leaf Green, Diamond and Pearl run, are, in effect, small computers, and thus also utilise binary numbers. The Pokemon games, however, have an extra simplification: they always use non-negative whole numbers only. This makes our discussion of binary numbers easier. How do we interpret a binary number? To do this, let’s think for a moment about how we interpret decimal numbers. What does the number 635, say, mean? It means a number that has 5 units, 3 tens (= 1 × 10) and 6 hundreds (= 10 × 10) added together. Notice that the value of a digit in the decimal system is ten times as big as that of the digit immediately to the right of it. So the number 635 really means 600 + 30 + 5. The same thing happens in binary, except that the value of a digit in the binary system is twice as big as that of the bit immediately to the right of it, not ten times as big. Let’s provide an example. Say we need to interpret the binary number 10001110 as a number in the decimal (i.e. normal) system. We have 0 units, 1 twos (= 1 × 2), 1 fours (= 2 × 2), 1 eights (= 4 × 2), 0 sixteens (= 8 × 2), 0 thirty-twos (= 16 × 2), 0 sixty-fours (= 32 × 2) and 1 one-hundred-and-twenty-eights (= 64 × 2). Thus, the binary number 10001110 is equal to 2 + 4 + 8 + 128 = 142. Another example: let’s interpret the 12-bit binary number 101110010101 as a number in decimal. It is equal to 1 units, 0 twos, 1 fours, 0 eights, 1 sixteens, 0 thirty-twos, 0 sixty-fours, 1 one-hundred-and-twenty-eights, 1 two-hundred-and-fifty-sixes (= 128 × 2), 1 five-hundred-and-twelves (= 256 × 2), 0 one-thousand-and-twenty-fours (= 512 × 2) and 1 two-thousand-and-forty-eights (= 1024 × 2). Hence it is equal to 1 + 4 + 16 + 128 + 256 + 512 + 2048 = 2965. 1.2 The Hexadecimal System Binary numbers tend to have quite a large number of digits. A way to write binary numbers in a shorter way is the hexadecimal system. In the hexadecimal system, a binary number is first grouped into groups of four bits each. If the number of bits in the binary number is not divisible by 4, extra 0 bits are added at the start of the binary number so that the number of digits is divisible by 4. Then each group of four bits is replaced by a symbol as follows: Code: 0000 is replaced by 0 0001 is replaced by 1 0010 is replaced by 2 0011 is replaced by 3 0100 is replaced by 4 0101 is replaced by 5 0110 is replaced by 6 0111 is replaced by 7 1000 is replaced by 8 1001 is replaced by 9 1010 is replaced by A 1011 is replaced by B 1100 is replaced by C 1101 is replaced by D 1110 is replaced by E 1111 is replaced by F For example, the binary number 10001110 is written in hexadecimal as 8E. The first 4 bits are 1000, written as 8 in hexadecimal, while the last 4 bits are 1110, written as E. The binary number 101110010101 is written as B95 in hexadecimal (1011 = B, 1001 = 9, 0101 = 5). The binary number 1110000001 has 10 bits. We first add two zeros at the beginning so that it has 12 bits: 001110000001. Then we convert it to hexadecimal as 381 (0011 = 3, 1000 = 8, 0001 = 1). Of course, we can also convert hexadecimal numbers to binary numbers easily by doing the reverse process. For example, the hexadecimal number 5AF7 is equal to 0101101011110111 in binary (5 = 0101, A = 1010, F = 1111, 7 = 0111). From now on, a hexadecimal number will be written surrounded by square brackets  so as not to possibly confuse it with a decimal number. This is because the hexadecimal number  is a different number from the decimal number 4680. 1.3 What is a PID? Whenever a Pokemon is created in the games, the first thing that is generated is a 32-bit number called a PID (Pokemon IDentification number). This number is sometimes also called the Personality Value of a Pokemon, and is not visible anywhere in the game. It can only be found by looking into the Pokemon save file... or by an applet that will be revealed soon. A lot of information about the Pokemon can be found using just the PID alone. In particular, the nature of a Pokemon is found just from its PID. Where applicable, the gender, ability and Unown letter shape are also found just from the PID of the Pokemon in question. 1.4 The Pokemon Random Number Generator Whenever a random event occurs in the Pokemon games, and indeed in the majority of games, the randomness of the event is not truly random, but is governed by a mathematical formula that generates so-called pseudo-random numbers. When we say pseudo-random, we mean that the numbers generated are not truly random numbers, but are sort-of fake random numbers. There are various methods that can be used to generate pseudo-random numbers. One of the simplest types of random number generators is the class of linear congruential random number generators. Many computer applications adopt this method of random number generation, as, while it is very simple to implement, it produces good random numbers when given particular values. By "good random numbers" we mean that if the numbers were to be listed next to each other, we wouldn’t have a clue as to what the next pseudo-random number would be in the list unless we apply the formula. The random number generator (RNG) used in all the Pokemon games from Ruby and Sapphire onwards works as follows. When the game loads, the program assigns a number to a 32-bit variable which we shall call seed. The way this is done varies from game to game (you can read loadingNOW’s article for more information). Then, whenever the random number generator is invoked, the following steps are executed: Code: Make seed equal to the last 32 bits of (seed × [41C64E6D] + ) Output first 16 bits of seed as the next pseudo-random number Thus, as you can see, the Pokemon RNG produces pseudo-random 16-bit numbers, i.e. numbers between 0 and 65535 (or between  and [FFFF]). For instance, given the seed [1A56B091], what is the random number that the above RNG outputs? First we need to multiply [1A56B091] by [41C64E6D]. Using a calculator, the answer of this multiplication is [6C469F301DB5BBD]. We now add  to this, becoming [6C469F301DBBC30]. Remember that a computer adds and multiplies numbers only in binary, so multiplying and adding hexadecimal numbers is very easy for it. Windows’ own calculator application allows multiplication and addition of hexadecimal numbers to be done easily, if you want to do them yourself. We now make the new seed equal to the last 32 bits of this hexadecimal number, or [01DBBC30] (remember that a hexadecimal digit is 4 bits). The random number produced is thus the first 16 bits of this new seed, or [01DB]. Repeatedly invoking the RNG produces the following list of pseudo-random numbers: [01DB], [7B06], , [E470], [5CC4], [36BB], ... It can be shown that the seed variable will become the same as it was at the start of the program only after the RNG is invoked 4,294,967,296 times. In all those RNG invocations, the variable seed would have become equal to every number between 0 and 4,294,967,295 (or between  and [FFFFFFFF]) exactly once. This essentially means that the random number sequence won’t repeat itself until after that amount of invocations. 2. Pokemon Creation 2.1 How the PID of a Pokemon is created The game creates a PID from two RNG calls. Since each RNG call results in a 16-bit number, appending these two 16-bit numbers together results in a 32-bit number, which becomes the PID of the Pokemon. The second random number becomes the first 16 bits of the PID, and the first random number becomes the second 16 bits. For example, suppose the two random numbers generated were [01DB] and [7B06] as above. Then the PID of the Pokemon would be [7B0601DB], or 2063991259 in decimal. 2.2 How to extract information about the Pokemon from its PID As was said before, a lot of things about a Pokemon can be known from just its PID. Here, we shall mention only three of these: nature, gender and ability. 2.2.1 How to find the nature of a Pokemon from its PID First, convert the PID to decimal as described at the start of the article, and consider only this decimal number’s last two digits. If the number having these two digits is greater than 24, subtract 25 from it, and repeat this procedure until it becomes a number between 0 and 24. This number then corresponds to a particular nature according to the following table: Code: Number Nature ----------------- 0 Hardy 1 Lonely 2 Brave 3 Adamant 4 Naughty 5 Bold 6 Docile 7 Relaxed 8 Impish 9 Lax 10 Timid 11 Hasty 12 Serious 13 Jolly 14 Naive 15 Modest 16 Mild 17 Quiet 18 Bashful 19 Rash 20 Calm 21 Gentle 22 Sassy 23 Careful 24 Quirky 2.2.2 How to find the gender of a Pokemon from its PID This only applies to Pokemon that can be either male or female. If a Pokemon is always genderless (for example Staryu), always male (for example Tauros) or always female (for example Chansey), the Pokemon will, of course, always assume that gender. For the other Pokemon, first take the last two digits of the PID in hexadecimal form and convert that number to decimal. This number should be between 0 and 255. As is commonly known, some Pokemon are more probable to be of one gender than another (for example Bulbasaur). There are four gender categories in all, other than the genderless, always male and always female categories: Pokemon that have a 12.5% chance of being female In this case, the Pokemon will be female if the number found above is between 0 and 30 inclusive, otherwise it will be male. Pokemon that have a 25% chance of being female In this case, the Pokemon will be female if the number found above is between 0 and 63 inclusive, otherwise it will be male. Pokemon that have a 50% chance of being female In this case, the Pokemon will be female if the number found above is between 0 and 126 inclusive, otherwise it will be male. Pokemon that have a 75% chance of being female In this case, the Pokemon will be female if the number found above is between 0 and 190 inclusive, otherwise it will be male. 2.2.3 How to find the ability of a Pokemon from its PID This only applies to Pokemon that can have one of two possible abilities. If a Pokemon can have only one ability, then it will have that ability, of course. For the other Pokemon that can have one of two abilities, first convert the PID to binary, and look at the last bit. If it is 0, the Pokemon will have its first possible ability, while if it is 1, it will have the second possible ability. The following table lists all Pokemon having two possible abilities, showing which ability corresponds to 0 and which corresponds to 1 in Diamond and Pearl (thanks yamipoli for providing this chart): Code: Pokemon Ability 0 Ability 1 -------------------------------------- Pidgey Keen Eye Tangled Feet Pidgeotto Keen Eye Tangled Feet Pidgeot Keen Eye Tangled Feet Rattata Run Away Guts Raticate Run Away Guts Ekans Intimidate Shed Skin Arbok Intimidate Shed Skin Nidoran-F Poison Point Rivalry Nidorina Poison Point Rivalry Nidoqueen Poison Point Rivalry Nidoran-M Poison Point Rivalry Nidorino Poison Point Rivalry Nidoking Poison Point Rivalry Cleffa Cute Charm Magic Guard Clefairy Cute Charm Magic Guard Clefable Cute Charm Magic Guard Paras Effect Spore Dry Skin Parasect Effect Spore Dry Skin Venonat Compoundeyes Tinted Lens Venomoth Shield Dust Tinted Lens Diglett Sand Veil Arena Trap Dugtrio Sand Veil Arena Trap Meowth Pick Up Technician Persian Pick Up Technician Psyduck Damp Cloud Nine Golduck Damp Cloud Nine Mankey Vital Spirit Anger Point Primeape Vital Spirit Anger Point Growlithe Intimidate Flash Fire Arcanine Intimidate Flash Fire Poliwag Water Absorb Damp Poliwhirl Water Absorb Damp Poliwrath Water Absorb Damp Politoed Water Absorb Damp Abra Synchronize Inner Focus Kadabra Synchronize Inner Focus Alakazam Synchronize Inner Focus Machop Guts No Guard Machoke Guts No Guard Machamp Guts No Guard Tentacool Clear Body Liquid Ooze Tentacruel Clear Body Liquid Ooze Geodude Rock Head Sturdy Graveler Rock Head Sturdy Golem Rock Head Sturdy Ponyta Run Away Flash Fire Rapidash Run Away Flash Fire Slowpoke Oblivious Own Tempo Slowbro Oblivious Own Tempo Slowking Oblivious Own Tempo Magnemite Magnet Pull Sturdy Magneton Magnet Pull Sturdy Magnezone Magnet Pull Sturdy Farfetch’d Keen Eye Inner Focus Doduo Run Away Early Bird Dodrio Run Away Early Bird Seel Thick Fat Hydration Dewgong Thick Fat Hydration Grimer Stench Sticky Hold Muk Stench Sticky Hold Shellder Shell Armor Skill Link Cloyster Shell Armor Skill Link Onix Rock Head Sturdy Steelix Rock Head Sturdy Drowzee Insomnia Forewarn Hypno Insomnia Forewarn Krabby Hyper Cutter Shell Armor Kingler Hyper Cutter Shell Armor Voltorb Soundproof Static Electrode Soundproof Static Cubone Rock Head Lightningrod Marowak Rock Head Lightningrod Tyrogue Guts Steadfast Hitmonlee Limber Reckless Hitmonchan Keen Eye Iron Fist Hitmontop Intimidate Technician Lickitung Own Tempo Oblivious Lickilicky Own Tempo Oblivious Rhyhorn Lightningrod Rock Head Rhydon Lightningrod Rock Head Rhyperior Lightningrod Solid Rock Happiny Natural Cure Serene Grace Chansey Natural Cure Serene Grace Blissey Natural Cure Serene Grace Tangela Chlorophyll Leaf Guard Tangrowth Chlorophyll Leaf Guard Kangaskhan Early Bird Scrappy Horsea Swift Swim Sniper Seadra Swift Swim Sniper Kingdra Swift Swim Sniper Goldeen Swift Swim Water Veil Seaking Swift Swim Water Veil Staryu Illuminate Natural Cure Starmie Illuminate Natural Cure Mime Jr. Soundproof Filter Mr. Mime Soundproof Filter Scyther Swarm Technician Scizor Swarm Technician Smoochum Oblivious Forewarn Jynx Oblivious Forewarn Pinsir Hyper Cutter Mold Breaker Tauros Intimidate Anger Point Lapras Water Absorb Shell Armor Eevee Run Away Adaptability Porygon Trace Download Porygon2 Trace Download Porygon-Z Adaptability Download Omanyte Swift Swim Shell Armor Omastar Swift Swim Shell Armor Kabuto Swift Swim Battle Armor Kabutops Swift Swim Battle Armor Aerodactyl Rock Head Pressure Munchlax Pick Up Thick Fat Snorlax Immunity Thick Fat Sentret Run Away Keen Eye Furret Run Away Keen Eye Hoothoot Insomnia Keen Eye Noctowl Insomnia Keen Eye Ledyba Swarm Early Bird Ledian Swarm Early Bird Spinarak Swarm Insomnia Ariados Swarm Insomnia Chinchou Volt Absorb Illuminate Lanturn Volt Absorb Illuminate Togepi Hustle Serene Grace Togetic Hustle Serene Grace Togekiss Hustle Serene Grace Natu Synchronize Early Bird Xatu Synchronize Early Bird Azurill Thick Fat Huge Power Marill Thick Fat Huge Power Azumarill Thick Fat Huge Power Bonsly Sturdy Rock Head Sudowoodo Sturdy Rock Head Aipon Run Away Pick Up Ambipom Technician Pick Up Sunkern Chlorophyll Solar Power Sunflora Chlorophyll Solar Power Yanma Speed Boost Compoundeyes Yanmega Speed Boost Tinted Lens Wooper Damp Water Absorb Quagsire Damp Water Absorb Murkrow Insomnia Super Luck Honchkrow Insomnia Super Luck Girafarig Inner Focus Early Bird Dunsparce Serene Grace Run Away Gligar Hyper Cutter Sand Veil Gliscor Hyper Cutter Sand Veil Snubbull Intimidate Run Away Granbull Intimidate Quick Feet Qwilfish Poison Point Swift Swim Heracross Swarm Guts Sneasel Inner Focus Keen Eye Teddiursa Pick Up Quick Feet Ursaring Guts Quick Feet Slugma Magma Armor Flame Body Magcargo Magma Armor Flame Body Swinub Oblivious Snow Cloak Piloswine Oblivious Snow Cloak Mamoswine Oblivious Snow Cloak Corsola Hustle Natural Cure Remoraid Hustle Sniper Octillery Suction Cups Sniper Delibird Vital Spirit Hustle Mantyke Swift Swim Water Absorb Mantine Swift Swim Water Absorb Skarmory Keen Eye Sturdy Houndour Early Bird Flash Fire Houndoom Early Bird Flash Fire Stantler Intimidate Frisk Smeargle Own Tempo Technician Miltank Thick Fat Scrappy Poochyena Run Away Quick Feet Mightyena Intimidate Quick Feet Zigzagoon Pick Up Gluttony Linoone Pick Up Gluttony Lotad Swift Swim Rain Dish Lombre Swift Swim Rain Dish Ludicolo Swift Swim Rain Dish Seedot Chlorophyll Early Bird Nuzleaf Chlorophyll Early Bird Shiftry Chlorophyll Early Bird Ralts Synchronize Trace Kirlia Synchronize Trace Gardevoir Synchronize Trace Shroomish Effect Spore Poison Heal Breloom Effect Spore Poison Heal Makuhita Thick Fat Guts Hariyama Thick Fat Guts Nosepass Sturdy Magnet Pull Probopass Sturdy Magnet Pull Skitty Cute Charm Normalize Delcatty Cute Charm Normalize Sableye Keen Eye Stall Mawile Hyper Cutter Intimidate Aron Sturdy Rock Head Lairon Sturdy Rock Head Aggron Sturdy Rock Head Electrike Static Lightningrod Manectric Static Lightningrod Volbeat Illuminate Swarm Illumise Oblivious Tinted Lens Budew Natural Cure Poison Point Roselia Natural Cure Poison Point Roserade Natural Cure Poison Point Gulpin Liquid Ooze Sticky Hold Swalot Liquid Ooze Sticky Hold Wailmer Water Veil Oblivious Wailord Water Veil Oblivious Numel Oblivious Simple Camerupt Magma Armor Solid Rock Spoink Thick Fat Own Tempo Grumpig Thick Fat Own Tempo Spinda Own Tempo Tangled Feet Trapinch Hyper Cutter Arena Trap Barboach Oblivious Anticipation Whiscash Oblivious Anticipation Corphish Hyper Cutter Shell Armor Crawdaunt Hyper Cutter Shell Armor Shuppet Insomnia Frisk Banette Insomnia Frisk Tropius Chlorophyll Solar Power Absol Pressure Super Luck Snorunt Inner Focus Ice Body Glalie Inner Focus Ice Body Spheal Thick Fat Ice Body Sealeo Thick Fat Ice Body Walrein Thick Fat Ice Body Relicanth Swift Swim Rock Head Bidoof Simple Unaware Bibarel Simple Unaware Shinx Rivalry Intimidate Luxio Rivalry Intimidate Luxray Rivalry Intimidate Pachirisu Run Away Pick Up Shellos Sticky Hold Storm Drain Gastrodon Sticky Hold Storm Drain Drifloon Aftermath Unburden Drifblim Aftermath Unburden Buneary Run Away Klutz Lopunny Cute Charm Klutz Glameow Limber Own Tempo Purugly Thick Fat Own Tempo Stunky Stench Aftermath Skuntank Stench Aftermath Bronzor Levitate Heatproof Bronzong Levitate Heatproof Chatot Keen Eye Tangled Feet Riolu Steadfast Inner Focus Lucario Steadfast Inner Focus Skorupi Battle Armor Sniper Drapion Battle Armor Sniper Croagunk Anticipation Dry Skin Toxicroak Anticipation Dry Skin Finneon Swift Swim Storm Drain Lumineon Swift Swim Storm Drain 2.3 How the IVs of a Pokemon are created The six IVs of the Pokemon are also created from just two RNG calls. Since each IV consists of 5 bits (because the binary number 11111 is equal to 31 in decimal), the first random number would contain 3 of these IVs (5 × 3 = 15), with one redundant bit, while the second random number would contain the other 3. The IVs would be extracted from the two random numbers as follows: Code: First Random Number: x|xxxxx|xxxxx|xxxxx -|DefIV|AtkIV|HP IV Second Random Number: x|xxxxx|xxxxx|xxxxx -|SpDIV|SpAIV|SpeIV For example, given the subsequent two random numbers  and [E470] as above, we would have: First Random Number =  = 0|10100|10001|10011. Hence, the Defense IV would be 10100 = 20, the Attack IV would be 10001 = 17 and the HP IV would be 10011 = 19. Second Random Number = [E470] = 1|11001|00011|10000. Hence, the Special Defense IV would be 11001 = 25, the Special Attack IV would be 00011 = 3 and the Speed IV would be 10000 = 16. Thus, our Pokemon would have the IVs 19/17/20/3/25/16, written in the usual format of HP IV/Atk IV/Def IV/SpA IV/SpD IV/Spe IV. 2.4 How the RNG is called in the games to generate a Pokemon There are basically three different ways of how the RNG is invoked to produce a Pokemon, depending on the game and the Pokemon: Method 1: Four RNG calls are made, two to generate the PID and two to generate the IVs. It can be illustrated as [PID] [PID] [IVs] [IVs]. Method 2: Five RNG calls are made. The first two are used to generate the PID and the last two are used to generate the IVs. The third RNG call is not used for anything. It can be illustrated as [PID] [PID] [xxxx] [IVs] [IVs]. Method 3: Five RNG calls are made. The first and third are used to generate the PID and the last two are used to generate the IVs. The second RNG call is not used for anything. It can be illustrated as [PID] [xxxx] [PID] [IVs] [IVs]. Methods 2 and 3 are only used in Pokemon Ruby, Sapphire, Emerald, Fire Red and Leaf Green (RSEFRLG) to produce wild Pokemon. All the Pokemon you catch in these games that are not wild Pokemon are created using Method 1. Examples of non-wild Pokemon that you can catch or be given in the game are: Legendary Pokemon Starter Pokemon Eevee in Fire Red and Leaf Green Castform and Beldum in Ruby, Sapphire and Emerald Method 1 is also used for some RSEFRLG wild Pokemon and for all Diamond and Pearl Pokemon, whether they are wild or not. The criterion for choosing whether to use Method 1, 2 or 3 in the creation of wild Pokemon in Ruby, Sapphire, Fire Red and Leaf Green seems to be arbitrary, although it might be related to the terrain where they are situated. To summarise, here are the methods used for each game depending on the Pokemon being caught or given: Code: Game Wild Pokemon Methods Non-wild Pokemon Methods --------------------------------------------------------- RSFRLGE 1, 2 or 3 1 DP 1 1 3. A Complete Example Suppose you meet a wild Tentacool in Emerald. Let’s assume that Method 2 is chosen for Tentacool to be generated. Also we assume that the current RNG seed is [560B9CE3]. The game calls the RNG and gets the number . The game calls the RNG again and gets the number [7E48]. Thus, the PID of this Tentacool is [7E482751]. This hexadecimal number is the 32-bit binary number 01111110010010000010011101010001 which is equal to 2118657873 in decimal. The last two digits of this decimal number are 73. Since this number is greater than 24, we subtract 25 from it. 73 minus 25 is equal to 48. 48 is still greater than 24, so we again subtract 25 from it, becoming 23. Hence this Tentacool would have a Careful nature, since that is the nature that the number 23 corresponds to. The last two digits of the PID in hexadecimal are 51, which is equal to 01010001 in binary, or 81 in decimal. Tentacool has a 50% chance of being female. Since the number 81 is between 0 and 126, this Tentacool would be female. The last digit of the binary representation of the PID is 1. Thus, this Tentacool would have the second possible ability, i.e. Liquid Ooze. The game now calls the RNG for a third time, getting the number [CAB4]. This number is discarded since we’re using Method 2 to generate the Pokemon. A fourth call to the RNG yields the number [629C]. This number is equal to 0|11000|10100|11100 in binary. The Defense IV would then be the binary number 11000, which is 24 in decimal, the Attack IV would be 10100, which is 20 in decimal, and the HP IV would be 11100, which is 28 in decimal. A final invocation to the RNG gives us the number [5EE9]. This number is equal to 0|10111|10111|01001 in binary. The Special Defense IV would thus be the binary number 10111, which is 23 in decimal, the Special Attack IV would be 10111, which is 23 in decimal and the Speed IV would be 01001, which is 9 in decimal. To recapitulate, you would have encountered a female Tentacool having a Careful nature, the Liquid Ooze ability and 28/20/24/23/23/9 IVs.