[???] The Process of PID and IV Creation of Non-Bred Pokemon HTML Edit

HTML:
[title]
The Process of PID and IV Creation of Non-Bred Pokemon
[head]
<meta name="description" content="The Process of PID and IV Creation of Non-Bred Pokemon" />
[page]
<div class="author">By <a href="/forums/member.php?u=2412">X-Act</a>.</div>

<ol class="toc">
    <li><a href="#credits">Credits</a></li>
    <li>
        <a href="#preliminaries">Preliminaries</a>
        <ol>
            <li><a href="#binary_system">The Binary System</a></li>
            <li><a href="#hexadecimal_system">The Hexadecimal System</a></li>
            <li><a href="#what_is_a_pid">What is a PID?</a></li>
            <li><a href="#what_is_a_pid">The Pokemon Random Number Generator</a></li>
        </ol>
    </li>
    <li>
        <a href="#pokemon_creation">Pokemon Creation</a>
        <ol>
            <li><a href="#pid_creation">How the PID of a Pokemon is created</a></li>
            <li>
                <a href="#extracting_information_from_pid">How to extract information from its PID</a>
                <ol>
                    <li><a href="#finding_nature_from_pid">How to find the nature of a Pokemon from its PID</a></li>
                    <li><a href="#finding_gender_from_pid">How to find the gender of a Pokemon from its PID</a></li>
                    <li><a href="#finding_ability_from_pid">How to find the ability of a Pokemon from its PID</a></li>
                </ol>
            </li>
            <li><a href="#iv_creation">How the IVs of a Pokemon are created</a></li>
            <li><a href="#rng_pokemon_generation">How the RNG is called in the games to generate a Pokemon</a></li>
        </ol>
    </li>
    <li><a href="#example">A Complete Example</a></li>
</ol>

<h2><a name="credits">Credits</a></h2>
 
<p>Before I even start, I need to give credit to <a href="/forums/member.php?u=8067">loadingNOW</a> (a.k.a. pika) and <a href="/forums/member.php?u=6196">yamipoli</a> for providing me with invaluable information regarding this topic.</p>
 
 
<h2><a name="preliminaries">Preliminaries</a></h2>
 
<p>We start by providing preliminary information, without which the reader will have a very hard time understanding this article.</p>
 
<h3><a name="binary_system">The Binary System</a></h3>
 
<p>In a computer, numbers are not stored normally, but in a format called <strong>binary</strong>. The numbers we normally use are said to be in the <strong>decimal</strong> 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 <strong>bit</strong> (short for <strong>bi</strong>nary digi<strong>t</strong>). For example, the binary number 10001110 has 8 bits.</p>
 
<p>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.</p>
 
<p>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.</p>
 
<p>The same thing happens in binary, except that the value of a digit in the binary system is <strong>twice as big</strong> as that of the bit immediately to the right of it, not ten times as big.</p>
 
<p>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 = <strong>142</strong>.</p>
 
<p>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 = <strong>2965</strong>.</p>
 
<h3><a name="hexadecimal_system">The Hexadecimal System</a></h3>
 
<p>Binary numbers tend to have quite a large number of digits. A way to write binary numbers in a shorter way is the <strong>hexadecimal system</strong>.</p>
 
<p>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:</p>
 
<ul>
    <li><var>0000</var> is replaced by <var>0</var></li>
    <li><var>0001</var> is replaced by <var>1</var></li>
    <li><var>0010</var> is replaced by <var>2</var></li>
    <li><var>0011</var> is replaced by <var>3</var></li>
    <li><var>0100</var> is replaced by <var>4</var></li>
    <li><var>0101</var> is replaced by <var>5</var></li>
    <li><var>0110</var> is replaced by <var>6</var></li>
    <li><var>0111</var> is replaced by <var>7</var></li>
    <li><var>1000</var> is replaced by <var>8</var></li>
    <li><var>1001</var> is replaced by <var>9</var></li>
    <li><var>1010</var> is replaced by <var>A</var></li>
    <li><var>1011</var> is replaced by <var>B</var></li>
    <li><var>1100</var> is replaced by <var>C</var></li>
    <li><var>1101</var> is replaced by <var>D</var></li>
    <li><var>1110</var> is replaced by <var>E</var></li>
    <li><var>1111</var> is replaced by <var>F</var></li>
</ul>
 
<p>For example, the binary number 10001110 is written in hexadecimal as <strong>8E</strong>. 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 <strong>B95</strong> 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 <strong>381</strong> (0011 = 3, 1000 = 8, 0001 = 1).</p>
 
<p>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).</p>
 
<p>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 [4680] is a different number from the decimal number 4680.</p>
 
<h3><a name="what_is_a_pid">What is a PID?</a></h3>
 
<p>Whenever a Pokemon is created in the games, the first thing that is generated is a 32-bit number called a <strong>PID</strong> (<strong>Pokemon IDentification</strong> number). This number is sometimes also called the <strong>Personality Value</strong> 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.</p>
 
<h3><a name="pokemon_random_number_generator">The Pokemon Random Number Generator</a></h3>
 
<p>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 <strong>pseudo-random numbers</strong>. When we say pseudo-random, we mean that the numbers generated are not truly random numbers, but are sort-of fake random numbers.</p>
 
<p>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 <strong>linear congruential random number generators</strong>. 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.</p>
 
<p>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 <strong>seed</strong>. 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:</p>
 
<ul>
    <li>Make seed equal to the last 32 bits of <var>(seed × [41C64E6D] + [6073])</var></li>
    <li>Output first 16 bits of seed as the next pseudo-random number</li>
</ul>
 
<p>Thus, as you can see, the Pokemon RNG produces pseudo-random 16-bit numbers, i.e. numbers between 0 and 65535 (or between [0000] and [FFFF]).</p>
 
<p>For instance, given the seed [1A56B091], what is the random number that the above RNG outputs?</p>
 
<p>First we need to multiply [1A56B091] by [41C64E6D]. Using a calculator, the answer of this multiplication is [6C469F301DB5BBD]. We now add [6073] 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 <strong>[01DB]</strong>.</p>
 
<p>Repeatedly invoking the RNG produces the following list of pseudo-random numbers:</p>
 
<p>[01DB], [7B06], [5233], [E470], [5CC4], [36BB], ...</p>
 
<p>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 [00000000] and [FFFFFFFF]) exactly once. This essentially means that the random number sequence won’t repeat itself until after that amount of invocations.</p>
 
 
<h2><a name="pokemon_creation">Pokemon Creation</a></h2>
 
<h3><a name="pid_creation">How the PID of a Pokemon is created</a></h3>
 
<p>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.</p>
 
<p>For example, suppose the two random numbers generated were [01DB] and [7B06] as above. Then the PID of the Pokemon would be <strong>[7B0601DB]</strong>, or 2063991259 in decimal.</p>
 
<h3><a name="extracting_information_from_pid">How to extract information about the Pokemon from its PID</a></h3>
 
<p>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.</p>
 
<h4><a name="finding_nature_from_pid">How to find the nature of a Pokemon from its PID</a></h4>
 
<p>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:</p>
 
<table class="sortable">
    <thead>
        <tr>
            <th>Number</th>
            <th>Nature</th>
        </tr>
    </thead>
    <tbody>
        <tr class="a"><td>0</td><td>Hardy</td></tr>
        <tr><td>1</td><td>Lonely</td></tr>
        <tr class="a"><td>2</td><td>Brave</td></tr>
        <tr><td>3</td><td>Adamant</td></tr>
        <tr class="a"><td>4</td><td>Naughty</td></tr>
        <tr><td>5</td><td>Bold</td></tr>
        <tr class="a"><td>6</td><td>Docile</td></tr>
        <tr><td>7</td><td>Relaxed</td></tr>
        <tr class="a"><td>8</td><td>Impish</td></tr>
        <tr><td>9</td><td>Lax</td></tr>
        <tr class="a"><td>10</td><td>Timid</td></tr>
        <tr><td>11</td><td>Hasty</td></tr>
        <tr class="a"><td>12</td><td>Serious</td></tr>
        <tr><td>13</td><td>Jolly</td></tr>
        <tr class="a"><td>14</td><td>Naive</td></tr>
        <tr><td>15</td><td>Modest</td></tr>
        <tr class="a"><td>16</td><td>Mild</td></tr>
        <tr><td>17</td><td>Quiet</td></tr>
        <tr class="a"><td>18</td><td>Bashful</td></tr>
        <tr><td>19</td><td>Rash</td></tr>
        <tr class="a"><td>20</td><td>Calm</td></tr>
        <tr><td>21</td><td>Gentle</td></tr>
        <tr class="a"><td>22</td><td>Sassy</td></tr>
        <tr><td>23</td><td>Careful</td></tr>
        <tr class="a"><td>24</td><td>Quirky</td></tr>
    </tbody>
</table>
 
<h4><a name="finding_gender_from_pid">How to find the gender of a Pokemon from its PID</a></h4>
 
<p>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.</p>
 
<p>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.</p>
 
<p>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:</p>

<dl>
    <dt>Pokemon that have a 12.5% chance of being female</dt>
    <dd>In this case, the Pokemon will be female if the number found above is between 0 and 30 inclusive, otherwise it will be male.</dd>
    
    <dt>Pokemon that have a 25% chance of being female</dt>
    <dd>In this case, the Pokemon will be female if the number found above is between 0 and 63 inclusive, otherwise it will be male.</dd>
    
    <dt>Pokemon that have a 50% chance of being female</dt>
    <dd>In this case, the Pokemon will be female if the number found above is between 0 and 126 inclusive, otherwise it will be male.</dd>
    
    <dt>Pokemon that have a 75% chance of being female</dt>
    <dd>In this case, the Pokemon will be female if the number found above is between 0 and 190 inclusive, otherwise it will be male.</dd>
</dl>

<h4><a name="finding_ability_from_pid">How to find the ability of a Pokemon from its PID</a></h4>
 
<p>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.</p>
 
<p>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 <strong>0</strong>, the Pokemon will have its first possible ability, while if it is <strong>1</strong>, it will have the second possible ability.</p>
 
<p>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):</p>
 
<table class="sortable">
    <thead>
        <tr>
            <th>Pokemon</th>
            <th>Ability 0</th>
            <th>Ability 1</th>
        </tr>
    </thead>
    <tbody>
        <tr class="a"><td>Pidgey</td><td>Keen Eye</td><td>Tangled Feet</td></tr>
        <tr><td>Pidgeotto</td><td>Keen Eye</td><td>Tangled Feet</td></tr>
        <tr class="a"><td>Pidgeot</td><td>Keen Eye</td><td>Tangled Feet</td></tr>
        <tr><td>Rattata</td><td>Run Away</td><td>Guts</td></tr>
        <tr class="a"><td>Raticate</td><td>Run Away</td><td>Guts</td></tr>
        <tr><td>Ekans</td><td>Intimidate</td><td>Shed Skin</td></tr>
        <tr class="a"><td>Arbok</td><td>Intimidate</td><td>Shed Skin</td></tr>
        <tr><td>Nidoran-F</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr class="a"><td>Nidorina</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr><td>Nidoqueen</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr class="a"><td>Nidoran-M</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr><td>Nidorino</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr class="a"><td>Nidoking</td><td>Poison Point</td><td>Rivalry</td></tr>
        <tr><td>Cleffa</td><td>Cute Charm</td><td>Magic Guard</td></tr>
        <tr class="a"><td>Clefairy</td><td>Cute Charm</td><td>Magic Guard</td></tr>
        <tr><td>Clefable</td><td>Cute Charm</td><td>Magic Guard</td></tr>
        <tr class="a"><td>Paras</td><td>Effect Spore</td><td>Dry Skin</td></tr>
        <tr><td>Parasect</td><td>Effect Spore</td><td>Dry Skin</td></tr>
        <tr class="a"><td>Venonat</td><td>Compoundeyes</td><td>Tinted Lens </td></tr>
        <tr><td>Venomoth</td><td>Shield Dust</td><td>Tinted Lens </td></tr>
        <tr class="a"><td>Diglett</td><td>Sand Veil</td><td>Arena Trap </td></tr>
        <tr><td>Dugtrio</td><td>Sand Veil</td><td>Arena Trap </td></tr>
        <tr class="a"><td>Meowth</td><td>Pick Up</td><td>Technician </td></tr>
        <tr><td>Persian</td><td>Pick Up</td><td>Technician </td></tr>
        <tr class="a"><td>Psyduck</td><td>Damp</td><td></td><td>Cloud Nine </td></tr>
        <tr><td>Golduck</td><td>Damp</td><td></td><td>Cloud Nine </td></tr>
        <tr class="a"><td>Mankey</td><td>Vital Spirit</td><td>Anger Point </td></tr>
        <tr><td>Primeape</td><td>Vital Spirit</td><td>Anger Point </td></tr>
        <tr class="a"><td>Growlithe</td><td>Intimidate</td><td>Flash Fire </td></tr>
        <tr><td>Arcanine</td><td>Intimidate</td><td>Flash Fire </td></tr>
        <tr class="a"><td>Poliwag</td><td>Water Absorb</td><td>Damp </td></tr>
        <tr><td>Poliwhirl</td><td>Water Absorb</td><td>Damp </td></tr>
        <tr class="a"><td>Poliwrath</td><td>Water Absorb</td><td>Damp </td></tr>
        <tr><td>Politoed</td><td>Water Absorb</td><td>Damp </td></tr>
        <tr class="a"><td>Abra</td><td>Synchronize</td><td>Inner Focus </td></tr>
        <tr><td>Kadabra</td><td>Synchronize</td><td>Inner Focus </td></tr>
        <tr class="a"><td>Alakazam</td><td>Synchronize</td><td>Inner Focus </td></tr>
        <tr><td>Machop</td><td>Guts</td><td></td><td>No Guard </td></tr>
        <tr class="a"><td>Machoke</td><td>Guts</td><td></td><td>No Guard </td></tr>
        <tr><td>Machamp</td><td>Guts</td><td></td><td>No Guard </td></tr>
        <tr class="a"><td>Tentacool</td><td>Clear Body</td><td>Liquid Ooze </td></tr>
        <tr><td>Tentacruel</td><td>Clear Body</td><td>Liquid Ooze </td></tr>
        <tr class="a"><td>Geodude</td><td>Rock Head</td><td>Sturdy </td></tr>
        <tr><td>Graveler</td><td>Rock Head</td><td>Sturdy </td></tr>
        <tr class="a"><td>Golem</td><td>Rock Head</td><td>Sturdy </td></tr>
        <tr><td>Ponyta</td><td>Run Away</td><td>Flash Fire </td></tr>
        <tr class="a"><td>Rapidash</td><td>Run Away</td><td>Flash Fire </td></tr>
        <tr><td>Slowpoke</td><td>Oblivious</td><td>Own Tempo </td></tr>
        <tr class="a"><td>Slowbro</td><td>Oblivious</td><td>Own Tempo </td></tr>
        <tr><td>Slowking</td><td>Oblivious</td><td>Own Tempo </td></tr>
        <tr class="a"><td>Magnemite</td><td>Magnet Pull</td><td>Sturdy </td></tr>
        <tr><td>Magneton</td><td>Magnet Pull</td><td>Sturdy </td></tr>
        <tr class="a"><td>Magnezone</td><td>Magnet Pull</td><td>Sturdy </td></tr>
        <tr><td>Farfetch’d</td><td>Keen Eye</td><td>Inner Focus </td></tr>
        <tr class="a"><td>Doduo</td><td>Run Away</td><td>Early Bird </td></tr>
        <tr><td>Dodrio</td><td>Run Away</td><td>Early Bird </td></tr>
        <tr class="a"><td>Seel</td><td>Thick Fat</td><td>Hydration </td></tr>
        <tr><td>Dewgong</td><td>Thick Fat</td><td>Hydration </td></tr>
        <tr class="a"><td>Grimer</td><td>Stench</td><td>Sticky Hold </td></tr>
        <tr><td>Muk</td><td>Stench</td><td>Sticky Hold </td></tr>
        <tr class="a"><td>Shellder</td><td>Shell Armor</td><td>Skill Link </td></tr>
        <tr><td>Cloyster</td><td>Shell Armor</td><td>Skill Link </td></tr>
        <tr class="a"><td>Onix</td><td>Rock Head</td><td>Sturdy </td></tr>
        <tr><td>Steelix</td><td>Rock Head</td><td>Sturdy </td></tr>
        <tr class="a"><td>Drowzee</td><td>Insomnia</td><td>Forewarn </td></tr>
        <tr><td>Hypno</td><td>Insomnia</td><td>Forewarn </td></tr>
        <tr class="a"><td>Krabby</td><td>Hyper Cutter</td><td>Shell Armor </td></tr>
        <tr><td>Kingler</td><td>Hyper Cutter</td><td>Shell Armor </td></tr>
        <tr class="a"><td>Voltorb</td><td>Soundproof</td><td>Static </td></tr>
        <tr><td>Electrode</td><td>Soundproof</td><td>Static </td></tr>
        <tr class="a"><td>Cubone</td><td>Rock Head</td><td>Lightningrod </td></tr>
        <tr><td>Marowak</td><td>Rock Head</td><td>Lightningrod </td></tr>
        <tr class="a"><td>Tyrogue</td><td>Guts</td><td></td><td>Steadfast </td></tr>
        <tr><td>Hitmonlee</td><td>Limber</td><td>Reckless </td></tr>
        <tr class="a"><td>Hitmonchan</td><td>Keen Eye</td><td>Iron Fist </td></tr>
        <tr><td>Hitmontop</td><td>Intimidate</td><td>Technician </td></tr>
        <tr class="a"><td>Lickitung</td><td>Own Tempo</td><td>Oblivious </td></tr>
        <tr><td>Lickilicky</td><td>Own Tempo</td><td>Oblivious </td></tr>
        <tr class="a"><td>Rhyhorn</td><td>Lightningrod</td><td>Rock Head </td></tr>
        <tr><td>Rhydon</td><td>Lightningrod</td><td>Rock Head </td></tr>
        <tr class="a"><td>Rhyperior</td><td>Lightningrod</td><td>Solid Rock </td></tr>
        <tr><td>Happiny</td><td>Natural Cure</td><td>Serene Grace </td></tr>
        <tr class="a"><td>Chansey</td><td>Natural Cure</td><td>Serene Grace </td></tr>
        <tr><td>Blissey</td><td>Natural Cure</td><td>Serene Grace </td></tr>
        <tr class="a"><td>Tangela</td><td>Chlorophyll</td><td>Leaf Guard </td></tr>
        <tr><td>Tangrowth</td><td>Chlorophyll</td><td>Leaf Guard </td></tr>
        <tr class="a"><td>Kangaskhan</td><td>Early Bird</td><td>Scrappy </td></tr>
        <tr><td>Horsea</td><td>Swift Swim</td><td>Sniper </td></tr>
        <tr class="a"><td>Seadra</td><td>Swift Swim</td><td>Sniper </td></tr>
        <tr><td>Kingdra</td><td>Swift Swim</td><td>Sniper </td></tr>
        <tr class="a"><td>Goldeen</td><td>Swift Swim</td><td>Water Veil </td></tr>
        <tr><td>Seaking</td><td>Swift Swim</td><td>Water Veil </td></tr>
        <tr class="a"><td>Staryu</td><td>Illuminate</td><td>Natural Cure </td></tr>
        <tr><td>Starmie</td><td>Illuminate</td><td>Natural Cure </td></tr>
        <tr class="a"><td>Mime Jr.</td><td>Soundproof</td><td>Filter </td></tr>
        <tr><td>Mr. Mime</td><td>Soundproof</td><td>Filter </td></tr>
        <tr class="a"><td>Scyther</td><td>Swarm</td><td>Technician </td></tr>
        <tr><td>Scizor</td><td>Swarm</td><td>Technician </td></tr>
        <tr class="a"><td>Smoochum</td><td>Oblivious</td><td>Forewarn </td></tr>
        <tr><td>Jynx</td><td>Oblivious</td><td>Forewarn </td></tr>
        <tr class="a"><td>Pinsir</td><td>Hyper Cutter</td><td>Mold Breaker </td></tr>
        <tr><td>Tauros</td><td>Intimidate</td><td>Anger Point </td></tr>
        <tr class="a"><td>Lapras</td><td>Water Absorb</td><td>Shell Armor </td></tr>
        <tr><td>Eevee</td><td>Run Away</td><td>Adaptability </td></tr>
        <tr class="a"><td>Porygon</td><td>Trace</td><td>Download</td></tr>
        <tr><td>Porygon2</td><td>Trace</td><td>Download </td></tr>
        <tr class="a"><td>Porygon-Z</td><td>Adaptability</td><td>Download </td></tr>
        <tr><td>Omanyte</td><td>Swift Swim</td><td>Shell Armor </td></tr>
        <tr class="a"><td>Omastar</td><td>Swift Swim</td><td>Shell Armor </td></tr>
        <tr><td>Kabuto</td><td>Swift Swim</td><td>Battle Armor </td></tr>
        <tr class="a"><td>Kabutops</td><td>Swift Swim</td><td>Battle Armor </td></tr>
        <tr><td>Aerodactyl</td><td>Rock Head</td><td>Pressure </td></tr>
        <tr class="a"><td>Munchlax</td><td>Pick Up</td><td>Thick Fat </td></tr>
        <tr><td>Snorlax</td><td>Immunity</td><td>Thick Fat </td></tr>
        <tr class="a"><td>Sentret</td><td>Run Away</td><td>Keen Eye </td></tr>
        <tr><td>Furret</td><td>Run Away</td><td>Keen Eye </td></tr>
        <tr class="a"><td>Hoothoot</td><td>Insomnia</td><td>Keen Eye </td></tr>
        <tr><td>Noctowl</td><td>Insomnia</td><td>Keen Eye </td></tr>
        <tr class="a"><td>Ledyba</td><td>Swarm</td><td>Early Bird </td></tr>
        <tr><td>Ledian</td><td>Swarm</td><td>Early Bird </td></tr>
        <tr class="a"><td>Spinarak</td><td>Swarm</td><td>Insomnia </td></tr>
        <tr><td>Ariados</td><td>Swarm</td><td>Insomnia </td></tr>
        <tr class="a"><td>Chinchou</td><td>Volt Absorb</td><td>Illuminate </td></tr>
        <tr><td>Lanturn</td><td>Volt Absorb</td><td>Illuminate </td></tr>
        <tr class="a"><td>Togepi</td><td>Hustle</td><td>Serene Grace </td></tr>
        <tr><td>Togetic</td><td>Hustle</td><td>Serene Grace </td></tr>
        <tr class="a"><td>Togekiss</td><td>Hustle</td><td>Serene Grace </td></tr>
        <tr><td>Natu</td><td>Synchronize</td><td>Early Bird </td></tr>
        <tr class="a"><td>Xatu</td><td>Synchronize</td><td>Early Bird </td></tr>
        <tr><td>Azurill</td><td>Thick Fat</td><td>Huge Power </td></tr>
        <tr class="a"><td>Marill</td><td>Thick Fat</td><td>Huge Power </td></tr>
        <tr><td>Azumarill</td><td>Thick Fat</td><td>Huge Power </td></tr>
        <tr class="a"><td>Bonsly</td><td>Sturdy</td><td>Rock Head </td></tr>
        <tr><td>Sudowoodo</td><td>Sturdy</td><td>Rock Head </td></tr>
        <tr class="a"><td>Aipon</td><td>Run Away</td><td>Pick Up </td></tr>
        <tr><td>Ambipom</td><td>Technician</td><td>Pick Up </td></tr>
        <tr class="a"><td>Sunkern</td><td>Chlorophyll</td><td>Solar Power </td></tr>
        <tr><td>Sunflora</td><td>Chlorophyll</td><td>Solar Power </td></tr>
        <tr class="a"><td>Yanma</td><td>Speed Boost</td><td>Compoundeyes </td></tr>
        <tr><td>Yanmega</td><td>Speed Boost</td><td>Tinted Lens </td></tr>
        <tr class="a"><td>Wooper</td><td>Damp</td><td></td><td>Water Absorb </td></tr>
        <tr><td>Quagsire</td><td>Damp</td><td></td><td>Water Absorb </td></tr>
        <tr class="a"><td>Murkrow</td><td>Insomnia</td><td>Super Luck </td></tr>
        <tr><td>Honchkrow</td><td>Insomnia</td><td>Super Luck </td></tr>
        <tr class="a"><td>Girafarig</td><td>Inner Focus</td><td>Early Bird </td></tr>
        <tr><td>Dunsparce</td><td>Serene Grace</td><td>Run Away </td></tr>
        <tr class="a"><td>Gligar</td><td>Hyper Cutter</td><td>Sand Veil </td></tr>
        <tr><td>Gliscor</td><td>Hyper Cutter</td><td>Sand Veil </td></tr>
        <tr class="a"><td>Snubbull</td><td>Intimidate</td><td>Run Away </td></tr>
        <tr><td>Granbull</td><td>Intimidate</td><td>Quick Feet </td></tr>
        <tr class="a"><td>Qwilfish</td><td>Poison Point</td><td>Swift Swim </td></tr>
        <tr><td>Heracross</td><td>Swarm</td><td>Guts </td></tr>
        <tr class="a"><td>Sneasel</td><td>Inner Focus</td><td>Keen Eye </td></tr>
        <tr><td>Teddiursa</td><td>Pick Up</td><td>Quick Feet </td></tr>
        <tr class="a"><td>Ursaring</td><td>Guts</td><td></td><td>Quick Feet </td></tr>
        <tr><td>Slugma</td><td>Magma Armor</td><td>Flame Body </td></tr>
        <tr class="a"><td>Magcargo</td><td>Magma Armor</td><td>Flame Body </td></tr>
        <tr><td>Swinub</td><td>Oblivious</td><td>Snow Cloak </td></tr>
        <tr class="a"><td>Piloswine</td><td>Oblivious</td><td>Snow Cloak </td></tr>
        <tr><td>Mamoswine</td><td>Oblivious</td><td>Snow Cloak </td></tr>
        <tr class="a"><td>Corsola</td><td>Hustle</td><td>Natural Cure </td></tr>
        <tr><td>Remoraid</td><td>Hustle</td><td>Sniper </td></tr>
        <tr class="a"><td>Octillery</td><td>Suction Cups</td><td>Sniper </td></tr>
        <tr><td>Delibird</td><td>Vital Spirit</td><td>Hustle </td></tr>
        <tr class="a"><td>Mantyke</td><td>Swift Swim</td><td>Water Absorb </td></tr>
        <tr><td>Mantine</td><td>Swift Swim</td><td>Water Absorb </td></tr>
        <tr class="a"><td>Skarmory</td><td>Keen Eye</td><td>Sturdy </td></tr>
        <tr><td>Houndour</td><td>Early Bird</td><td>Flash Fire </td></tr>
        <tr class="a"><td>Houndoom</td><td>Early Bird</td><td>Flash Fire </td></tr>
        <tr><td>Stantler</td><td>Intimidate</td><td>Frisk </td></tr>
        <tr class="a"><td>Smeargle</td><td>Own Tempo</td><td>Technician </td></tr>
        <tr><td>Miltank</td><td>Thick Fat</td><td>Scrappy </td></tr>
        <tr class="a"><td>Poochyena</td><td>Run Away</td><td>Quick Feet </td></tr>
        <tr><td>Mightyena</td><td>Intimidate</td><td>Quick Feet </td></tr>
        <tr class="a"><td>Zigzagoon</td><td>Pick Up</td><td>Gluttony </td></tr>
        <tr><td>Linoone</td><td>Pick Up</td><td>Gluttony </td></tr>
        <tr class="a"><td>Lotad</td><td>Swift Swim</td><td>Rain Dish </td></tr>
        <tr><td>Lombre</td><td>Swift Swim</td><td>Rain Dish </td></tr>
        <tr class="a"><td>Ludicolo</td><td>Swift Swim</td><td>Rain Dish </td></tr>
        <tr><td>Seedot</td><td>Chlorophyll</td><td>Early Bird </td></tr>
        <tr class="a"><td>Nuzleaf</td><td>Chlorophyll</td><td>Early Bird </td></tr>
        <tr><td>Shiftry</td><td>Chlorophyll</td><td>Early Bird </td></tr>
        <tr class="a"><td>Ralts</td><td>Synchronize</td><td>Trace </td></tr>
        <tr><td>Kirlia</td><td>Synchronize</td><td>Trace </td></tr>
        <tr class="a"><td>Gardevoir</td><td>Synchronize</td><td>Trace </td></tr>
        <tr><td>Shroomish</td><td>Effect Spore</td><td>Poison Heal </td></tr>
        <tr class="a"><td>Breloom</td><td>Effect Spore</td><td>Poison Heal </td></tr>
        <tr><td>Makuhita</td><td>Thick Fat</td><td>Guts </td></tr>
        <tr class="a"><td>Hariyama</td><td>Thick Fat</td><td>Guts </td></tr>
        <tr><td>Nosepass</td><td>Sturdy</td><td>Magnet Pull </td></tr>
        <tr class="a"><td>Probopass</td><td>Sturdy</td><td>Magnet Pull </td></tr>
        <tr><td>Skitty</td><td>Cute Charm</td><td>Normalize </td></tr>
        <tr class="a"><td>Delcatty</td><td>Cute Charm</td><td>Normalize </td></tr>
        <tr><td>Sableye</td><td>Keen Eye</td><td>Stall </td></tr>
        <tr class="a"><td>Mawile</td><td>Hyper Cutter</td><td>Intimidate </td></tr>
        <tr><td>Aron</td><td>Sturdy</td><td>Rock Head </td></tr>
        <tr class="a"><td>Lairon</td><td>Sturdy</td><td>Rock Head </td></tr>
        <tr><td>Aggron</td><td>Sturdy</td><td>Rock Head </td></tr>
        <tr class="a"><td>Electrike</td><td>Static</td><td>Lightningrod </td></tr>
        <tr><td>Manectric</td><td>Static</td><td>Lightningrod </td></tr>
        <tr class="a"><td>Volbeat</td><td>Illuminate</td><td>Swarm </td></tr>
        <tr><td>Illumise</td><td>Oblivious</td><td>Tinted Lens </td></tr>
        <tr class="a"><td>Budew</td><td>Natural Cure</td><td>Poison Point </td></tr>
        <tr><td>Roselia</td><td>Natural Cure</td><td>Poison Point </td></tr>
        <tr class="a"><td>Roserade</td><td>Natural Cure</td><td>Poison Point </td></tr>
        <tr><td>Gulpin</td><td>Liquid Ooze</td><td>Sticky Hold </td></tr>
        <tr class="a"><td>Swalot</td><td>Liquid Ooze</td><td>Sticky Hold </td></tr>
        <tr><td>Wailmer</td><td>Water Veil</td><td>Oblivious </td></tr>
        <tr class="a"><td>Wailord</td><td>Water Veil</td><td>Oblivious </td></tr>
        <tr><td>Numel</td><td>Oblivious</td><td>Simple </td></tr>
        <tr class="a"><td>Camerupt</td><td>Magma Armor</td><td>Solid Rock </td></tr>
        <tr><td>Spoink</td><td>Thick Fat</td><td>Own Tempo </td></tr>
        <tr class="a"><td>Grumpig</td><td>Thick Fat</td><td>Own Tempo </td></tr>
        <tr><td>Spinda</td><td>Own Tempo</td><td>Tangled Feet </td></tr>
        <tr class="a"><td>Trapinch</td><td>Hyper Cutter</td><td>Arena Trap </td></tr>
        <tr><td>Barboach</td><td>Oblivious</td><td>Anticipation</td></tr>
        <tr class="a"><td>Whiscash</td><td>Oblivious</td><td>Anticipation</td></tr>
        <tr><td>Corphish</td><td>Hyper Cutter</td><td>Shell Armor </td></tr>
        <tr class="a"><td>Crawdaunt</td><td>Hyper Cutter</td><td>Shell Armor </td></tr>
        <tr><td>Shuppet</td><td>Insomnia</td><td>Frisk </td></tr>
        <tr class="a"><td>Banette</td><td>Insomnia</td><td>Frisk </td></tr>
        <tr><td>Tropius</td><td>Chlorophyll</td><td>Solar Power </td></tr>
        <tr class="a"><td>Absol</td><td>Pressure</td><td>Super Luck </td></tr>
        <tr><td>Snorunt</td><td>Inner Focus</td><td>Ice Body </td></tr>
        <tr class="a"><td>Glalie</td><td>Inner Focus</td><td>Ice Body </td></tr>
        <tr><td>Spheal</td><td>Thick Fat</td><td>Ice Body </td></tr>
        <tr class="a"><td>Sealeo</td><td>Thick Fat</td><td>Ice Body </td></tr>
        <tr><td>Walrein</td><td>Thick Fat</td><td>Ice Body </td></tr>
        <tr class="a"><td>Relicanth</td><td>Swift Swim</td><td>Rock Head </td></tr>
        <tr><td>Bidoof</td><td>Simple</td><td>Unaware </td></tr>
        <tr class="a"><td>Bibarel</td><td>Simple</td><td>Unaware </td></tr>
        <tr><td>Shinx</td><td>Rivalry</td><td>Intimidate </td></tr>
        <tr class="a"><td>Luxio</td><td>Rivalry</td><td>Intimidate </td></tr>
        <tr><td>Luxray</td><td>Rivalry</td><td>Intimidate </td></tr>
        <tr class="a"><td>Pachirisu</td><td>Run Away</td><td>Pick Up </td></tr>
        <tr><td>Shellos</td><td>Sticky Hold</td><td>Storm Drain </td></tr>
        <tr class="a"><td>Gastrodon</td><td>Sticky Hold</td><td>Storm Drain </td></tr>
        <tr><td>Drifloon</td><td>Aftermath</td><td>Unburden </td></tr>
        <tr class="a"><td>Drifblim</td><td>Aftermath</td><td>Unburden </td></tr>
        <tr><td>Buneary</td><td>Run Away</td><td>Klutz </td></tr>
        <tr class="a"><td>Lopunny</td><td>Cute Charm</td><td>Klutz </td></tr>
        <tr><td>Glameow</td><td>Limber</td><td>Own Tempo </td></tr>
        <tr class="a"><td>Purugly</td><td>Thick Fat</td><td>Own Tempo </td></tr>
        <tr><td>Stunky</td><td>Stench</td><td>Aftermath </td></tr>
        <tr class="a"><td>Skuntank</td><td>Stench</td><td>Aftermath </td></tr>
        <tr><td>Bronzor</td><td>Levitate</td><td>Heatproof </td></tr>
        <tr class="a"><td>Bronzong</td><td>Levitate</td><td>Heatproof </td></tr>
        <tr><td>Chatot</td><td>Keen Eye</td><td>Tangled Feet </td></tr>
        <tr class="a"><td>Riolu</td><td>Steadfast</td><td>Inner Focus </td></tr>
        <tr><td>Lucario</td><td>Steadfast</td><td>Inner Focus </td></tr>
        <tr class="a"><td>Skorupi</td><td>Battle Armor</td><td>Sniper </td></tr>
        <tr><td>Drapion</td><td>Battle Armor</td><td>Sniper </td></tr>
        <tr class="a"><td>Croagunk</td><td>Anticipation</td><td>Dry Skin </td></tr>
        <tr><td>Toxicroak</td><td>Anticipation</td><td>Dry Skin </td></tr>
        <tr class="a"><td>Finneon</td><td>Swift Swim</td><td>Storm Drain </td></tr>
        <tr><td>Lumineon</td><td>Swift Swim</td><td>Storm Drain</td></tr>
    </tbody>
</table>
 
<h3><a name="iv_creation">How the IVs of a Pokemon are created</a></h3>
 
<p>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.</p>
 
<p>The IVs would be extracted from the two random numbers as follows:</p>
 
<pre>
First Random Number:  x|xxxxx|xxxxx|xxxxx
                      -|DefIV|AtkIV|HP IV
 
Second Random Number: x|xxxxx|xxxxx|xxxxx
                      -|SpDIV|SpAIV|SpeIV
</pre>
 
<p>For example, given the subsequent two random numbers [5233] and [E470] as above, we would have:</p>
 
<p>First Random Number = [5233] = 0|10100|10001|10011. Hence, the Defense IV would be 10100 = <strong>20</strong>, the Attack IV would be 10001 = <strong>17</strong> and the HP IV would be 10011 = <strong>19</strong>.</p>
 
<p>Second Random Number = [E470] = 1|11001|00011|10000. Hence, the Special Defense IV would be 11001 = <strong>25</strong>, the Special Attack IV would be 00011 = <strong>3</strong> and the Speed IV would be 10000 = <strong>16</strong>.</p>
 
<p>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.</p>
 
<h3><a name="rng_pokemon_generation">How the RNG is called in the games to generate a Pokemon</a></h3>
 
<p>There are basically three different ways of how the RNG is invoked to produce a Pokemon, depending on the game and the Pokemon:</p>

<dl>
    <dt>Method 1</dt>
    <dd>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].</dd>

    <dt>Method 2</dt>
    <dd>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].</dd>
    
    <dt>Method 3</dt>
    <dd>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].</dd>
</dl>
    
<p>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:

<ul>
    <li>Legendary Pokemon</li>
    <li>Starter Pokemon</li>
    <li>Eevee in Fire Red and Leaf Green</li>
    <li>Castform and Beldum in Ruby, Sapphire and Emerald</li>
</ul>

<p>Method 1 is also used for some RSEFRLG wild Pokemon and for all Diamond and Pearl Pokemon, whether they are wild or not.</p>
 
<p>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.</p>
 
<p>To summarise, here are the methods used for each game depending on the Pokemon being caught or given:</p>
 
<table class="sortable">
    <thead>
        <tr>
            <th>Game</th><th>Wild Pokemon Methods</th><th>Non-wild Pokemon Methods</th>
        </tr>
    </thead>
    <tbody>
        <tr class="a"><td>RSFRLGE</td><td>1, 2 or 3</td><td>1</td></tr>
        <tr><td>DP</td><td>1</td><td>1</td></tr>
    </tbody>
</table>
 
<h2><a name="example">A Complete Example</a></h2>
 
<p>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].</p>
 
<p>The game calls the RNG and gets the number [2751]. The game calls the RNG again and gets the number [7E48]. Thus, the PID of this Tentacool is [7E482751].</p>
 
<p>This hexadecimal number is the 32-bit binary number</p>
 
<pre>01111110010010000010011101010001</pre>
 
<p>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 <strong>Careful</strong> nature, since that is the nature that the number 23 corresponds to.</p>
 
<p>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 <strong>female</strong>.</p>
 
<p>The last digit of the binary representation of the PID is 1. Thus, this Tentacool would have the second possible ability, i.e. <strong>Liquid Ooze</strong>.</p>
 
<p>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 </p>
 
<pre>0|11000|10100|11100</pre>
 
<p>in binary. The Defense IV would then be the binary number 11000, which is <strong>24</strong> in decimal, the Attack IV would be 10100, which is <strong>20</strong> in decimal, and the HP IV would be 11100, which is <strong>28</strong> in decimal.</p>
 
<p>A final invocation to the RNG gives us the number [5EE9]. This number is equal to</p>
 
<pre>0|10111|10111|01001</pre>
 
<p>in binary. The Special Defense IV would thus be the binary number 10111, which is <strong>23</strong> in decimal, the Special Attack IV would be 10111, which is <strong>23</strong> in decimal and the Speed IV would be 01001, which is <strong>9</strong> in decimal.</p>
 
<p>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.</p>
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top