X-Act
np: Biffy Clyro - Shock Shock
6. More Things affected by the PID
6.1 How the Game Makes a Pokemon Shiny
Very rarely, you might encounter a Pokemon having a different coloration than usual. This is called a shiny Pokemon. The game’s criterion for making a shiny Pokemon depends in part on its PID, but also depends on two other numbers.
One of these numbers is visible in the game. It is called the Trainer ID. This is the number you have when you look at your Trainer card, and is a number between 0 and 65535 (between [0000] and [FFFF] in hexadecimal). The other number is also a number between 0 and 65535 but is unfortunately invisible to you. It is called the Secret ID. Currently, there’s no way you can know your Secret ID without looking at your save file or without using cheat codes.
So how does the game determine that a Pokemon is shiny? Here’s how.
Split the PID in two 16-bit numbers. That is, if the PID was [465DB901], it would split it in two as [465D] and [B901]. We shall call the first 4 hexadecimal digits the HID (high ID) and the last 4 hexadecimal digits the LID (Low ID). Now convert the HID, LID, Trainer ID (which we shall denote by TID for short) and Secret ID (denoted by SID for short) to binary, and compare the first 13 bits of all four, like so:
Here we’re counting the number of 1's in the first bit of the HID, LID, TID and SID. If there are either 1 or 3 ones among those bits, the Pokemon is automatically not shiny. If there aren’t, the game counts the second bits. Again, if there are either 1 or 3 ones among those bits, the Pokemon is automatically not shiny. The game checks the bits of the HID, LID, TID and SID up to their thirteenth one, and all of them would need to have 0, 2 or 4 ones for the Pokemon to be shiny! This is a one in 8192 (2 to the power of 13) chance of happening.
Let’s have an example. Suppose the Trainer ID of the player is 43288, or [A918] in hexadecimal, and the Secret ID is 6075, or [17BB] in hexadecimal. Suppose also that the PID of the Pokemon is [B58F0B2A]. We split the PID in two, the HID [B58F] and the LID [0B2A], and convert the HID, LID, Trainer ID and Secret ID to binary. Thus we would have:
We now count the number of bits in the first bit, second bit, third bit ... up to the thirteenth bit of each of these four 16-bit numbers.
Since counting the ones of each bit up to the thirteenth one in turn never yields a number that is not 1 or 3, the Pokemon will be shiny!
6.2 How to determine whether Wurmple evolves into Silcoon or into Cascoon
There are many hoaxes on the internet as to how Wurmple evolves into Silcoon or into Cascoon. Some say that it is determined by gender, other say it is determined by whether or not it is night or day. The truth is that it is determined from the PID of Wurmple as follows.
Look at the last 16 bits of the PID. We have called it the LID in the previous section. Convert the LID to decimal, and look at the last digit of this decimal number. If this digit is 0, 1, 2, 3 or 4, Wurmple would evolve into Silcoon. If the digit is 5, 6, 7, 8, or 9, Wurmple would evolve into Cascoon.
Let’s provide an example. Say a Wurmple has a PID of [5CF4091C]. The last 16 bits of the PID are [091C], which is equal to 2332 in decimal. Since the last digit of this decimal number is 2, this Wumple would evolve into Silcoon.
6.3 How to determine Unown’s shape
As claimed previously, even Unown’s shape is determined from its PID.
First convert the PID to binary. Look at the seventh, eighth, fifteenth, sixteenth, twenty-third, twenty-fourth, thirty-first and thirty-second bits of the PID, i.e. the ones underlined below:
Combine these 8 bits together to form an 8-bit number, and convert it to decimal. If this number is 28 or more, subtract 28 from this number until it is a number between 0 and 27. This number would then correspond to the Unown symbol according to the following table:
Let’s give an example. Suppose an Unown has PID [4C07DE71]. We first convert this PID to binary, getting
Combine the underlined bits together, getting 00111001, and convert it to decimal, getting 57. 57 is larger than 27, so it is subtracted by 28, becoming 29. 29 is again larger than 27, so it is subtracted by 28, getting 1. 1 corresponds to B, and hence the Unown would have the shape of a B.
6.4 How Spinda’s spots are determined
Spinda’s spots are the most useless thing ever implemented in the history of computer implementations, but, for the sake of completeness, we explain exactly how Spinda’s spots are placed on its rubbery body, because the PID, again, is the culprit.
Look at Spinda’s PID in hexadecimal. Convert each hexadecimal digit into decimal in turn. So, for example, if Spinda’s PID is [65492BDA], we would have 6 = 6, 5 = 5, 4 = 4, 9 = 9, 2 = 2, B = 11, D = 13 and A = 10. From these numbers, the co-ordinates (5, 6), (9, 4), (11, 2) and (10, 13) are thus constructed. These correspond to the coordinates of the upper-left hand corner of Spinda’s left face spot, its right face spot, its left ear spot and its right ear spot respectively. (Spinda’s left spots appear on the right in its front sprite and vice-versa.) All Spinda have exactly 4 spots. If some Spinda appear to have less than four spots, it is either because some spots are superimposed on each other or because the coordinate for some spots does not fall completely on Spinda’s sprite.
To put them in place, the game adds 18 to the x-coordinate and 19 to the y-coordinate of the left face spot. It also adds 6 to the x-coordinate and 18 to the y-coordinate of the right face spot. Lastly, it adds 24 to the x-coordinate and 1 to the y-coordinate of of the left ear spot. The right ear spot’s coordinates are left unchanged.
Thus we have:
7. The PID of Chained Shiny Pokemon
A new feature in Diamond and Pearl is the PokeRadar, which allows you to chain Pokemon. Chained Pokemon, besides having the advantage of always catching Pokemon of the same species, have a greater probability for them to appear shiny. This section explains in detail how the game determines whether or not a chained Pokemon is shiny, and how it constructs its PID so that it conforms to the criterion that appears in the previous section entitled ‘How the game makes a Pokemon shiny’.
7.1 The Probability of a Chained Pokemon to appear Shiny
This depends on the chain number you’ve attained, which cannot be greater than 40. Suppose your chain number is c. The probability that a chained Pokemon is shiny is governed by the following formula:
Hereunder is the probability of catching a shiny Pokemon knowing your chain length:
Notice that the probabilities are not very good unless your chain’s length becomes 30 or more, so aim for as long a chain as possible.
7.2 How the PID and IVs of a Chained Shiny Pokemon is created
First, the game calls the RNG twice to create the PID as usual. Remember that the first number generated would be the LID (last 16 bits) of the PID, while the second one would be the HID (first 16 bits) of the PID. The game now needs to ‘fix’ the PID such that the criterion for the Pokemon to appear shiny is attained. This is done as follows.
Convert the Trainer ID and Secret ID to binary, and look at their thirtheenth, twelfth, eleventh, etc. bits of both, until we reach their first bit. Suppose we’re looking at the i’th bit. For each of these pairs of bits, the RNG is called once and the resulting random number’s last bit is noted.
If the pair of bits at the i’th position of TID and SID are the same (i.e. either both are 0 or both are 1), the HID and LID’s i’th bits are both set to the last bit of the random number generated. If the pair of bits at the i’th position of TID and SID are different (i.e. one is 0 and the other one is 1), the LID’s i’th bit is set to the last bit of the random number generated, and the HID’s i’th bit is set to the reverse bit (1 if it was 0, 0 if it was 1) of the last bit of the random number generated.
Following this procedure, this would ensure that the number of 1’s in the i’th position of the TID, SID, HID and LID is either 0, 2 or 4. Since this would be true for all bits between the first and the thirteenth, the Pokemon would be ‘forced’ to appear shiny.
After this is done, there are two subsequent calls to the RNG to create the IVs as usual. Thus, the RNG is called 17 times in all to generate a chained shiny Pokemon: twice to generate the initial PID, 13 times to ‘fix’ the PID, and twice to generate the IVs.
7.3 An Example of generating the PID of a Chained Shiny Pokemon
Suppose the player encounters a chained shiny Pokemon. We suppose the player has Trainer ID (TID) 38710 and Secret ID (SID) 13099. We also suppose that the current RNG seed is [69AC550F]. We call the RNG twice, getting the numbers [18E5] and [1DD6]. Hence, the LID is [18E5] and the HID is [1DD6]. The numbers in binary are:
We now need to fix the HID and LID such that the Pokemon is shiny. We start looking from the thirteenth bit.
We call the RNG, getting [A013]. When converted to binary, its last digit is 1. (To know at a glance if the last bit of a hexadecimal number is 0 or 1, look at the last hexadecimal digit. If it is 0, 2, 4, 6, 8, A, C or E, the last bit would be 0, otherwise it would be 1.)
The TID and SID’s thirteenth bits are 0 and 1 respectively, hence they are different. Thus, we make the thirteenth bit of LID as 1 (last digit of the last random number generated) and the first bit of HID as 0. So we have:
Next we go to the twelfth bit. We generate another random number, getting [A4AE], whose last bit is 0. TID’s and SID’s twelfth bits are 1 and 0 respectively. Hence the twelfth bit of the LID is made to be 0 and the HID's twelfth bit is made to be 1.
Moving on to the eleventh bit, we call the RNG again, getting [77AD] whose last bit is 1. The TID and SID’s eleventh bit are both 1. Thus we make both the HID and the LID's eleventh bits to be 1.
For the tenth bit, we again call the RNG, getting [B237] whose last bit is 1. The TID and SID’s tenth bits are both 0. Thus we make the fourth bit of LID and HID both 1.
Continuing doing this until we reach the first bit, we get:
The last bit of each of the subsequent random numbers generated was 0, 1, 1, 1, 0, 0, 1, 1, 0 for the ninth, eighth, seventh, ... first bit respectively. As you can see, the HID and LID now satisfy the criterion for the Pokemon to appear shiny.
Thus the PID of the chained shiny Pokemon would be
which is equivalent to [C376676D] in hexadecimal, or 3279316845 in decimal. Two subsequent RNG calls would then be made to create the Pokemon’s IVs normally.
6.1 How the Game Makes a Pokemon Shiny
Very rarely, you might encounter a Pokemon having a different coloration than usual. This is called a shiny Pokemon. The game’s criterion for making a shiny Pokemon depends in part on its PID, but also depends on two other numbers.
One of these numbers is visible in the game. It is called the Trainer ID. This is the number you have when you look at your Trainer card, and is a number between 0 and 65535 (between [0000] and [FFFF] in hexadecimal). The other number is also a number between 0 and 65535 but is unfortunately invisible to you. It is called the Secret ID. Currently, there’s no way you can know your Secret ID without looking at your save file or without using cheat codes.
So how does the game determine that a Pokemon is shiny? Here’s how.
Split the PID in two 16-bit numbers. That is, if the PID was [465DB901], it would split it in two as [465D] and [B901]. We shall call the first 4 hexadecimal digits the HID (high ID) and the last 4 hexadecimal digits the LID (Low ID). Now convert the HID, LID, Trainer ID (which we shall denote by TID for short) and Secret ID (denoted by SID for short) to binary, and compare the first 13 bits of all four, like so:
Code:
HID: [U]x[/U]xxxxxxxxxxxx|xxx
LID: [U]x[/U]xxxxxxxxxxxx|xxx
TID: [U]x[/U]xxxxxxxxxxxx|xxx
SID: [U]x[/U]xxxxxxxxxxxx|xxx
Let’s have an example. Suppose the Trainer ID of the player is 43288, or [A918] in hexadecimal, and the Secret ID is 6075, or [17BB] in hexadecimal. Suppose also that the PID of the Pokemon is [B58F0B2A]. We split the PID in two, the HID [B58F] and the LID [0B2A], and convert the HID, LID, Trainer ID and Secret ID to binary. Thus we would have:
Code:
HID: 1011010110001|111
LID: 0000101100101|010
TID: 1010100100011|000
SID: 0001011110111|011
Code:
HID: 1011010110001|111
LID: 0000101100101|010
TID: 1010100100011|000
SID: 0001011110111|011
Ones: 2022222420224
6.2 How to determine whether Wurmple evolves into Silcoon or into Cascoon
There are many hoaxes on the internet as to how Wurmple evolves into Silcoon or into Cascoon. Some say that it is determined by gender, other say it is determined by whether or not it is night or day. The truth is that it is determined from the PID of Wurmple as follows.
Look at the last 16 bits of the PID. We have called it the LID in the previous section. Convert the LID to decimal, and look at the last digit of this decimal number. If this digit is 0, 1, 2, 3 or 4, Wurmple would evolve into Silcoon. If the digit is 5, 6, 7, 8, or 9, Wurmple would evolve into Cascoon.
Let’s provide an example. Say a Wurmple has a PID of [5CF4091C]. The last 16 bits of the PID are [091C], which is equal to 2332 in decimal. Since the last digit of this decimal number is 2, this Wumple would evolve into Silcoon.
6.3 How to determine Unown’s shape
As claimed previously, even Unown’s shape is determined from its PID.
First convert the PID to binary. Look at the seventh, eighth, fifteenth, sixteenth, twenty-third, twenty-fourth, thirty-first and thirty-second bits of the PID, i.e. the ones underlined below:
Code:
xxxxxx[U]xx[/U]xxxxxx[U]xx[/U]xxxxxx[U]xx[/U]xxxxxx[U]xx[/U]
Code:
Number Unown Shape
-------------------
0 A
1 B
2 C
3 D
4 E
5 F
6 G
7 H
8 I
9 J
10 K
11 L
12 M
13 N
14 O
15 P
16 Q
17 R
18 S
19 T
20 U
21 V
22 W
23 X
24 Y
25 Z
26 ?
27 !
Code:
010011[U]00[/U]000001[U]11[/U]110111[U]10[/U]011100[U]01[/U]
6.4 How Spinda’s spots are determined
Spinda’s spots are the most useless thing ever implemented in the history of computer implementations, but, for the sake of completeness, we explain exactly how Spinda’s spots are placed on its rubbery body, because the PID, again, is the culprit.
Look at Spinda’s PID in hexadecimal. Convert each hexadecimal digit into decimal in turn. So, for example, if Spinda’s PID is [65492BDA], we would have 6 = 6, 5 = 5, 4 = 4, 9 = 9, 2 = 2, B = 11, D = 13 and A = 10. From these numbers, the co-ordinates (5, 6), (9, 4), (11, 2) and (10, 13) are thus constructed. These correspond to the coordinates of the upper-left hand corner of Spinda’s left face spot, its right face spot, its left ear spot and its right ear spot respectively. (Spinda’s left spots appear on the right in its front sprite and vice-versa.) All Spinda have exactly 4 spots. If some Spinda appear to have less than four spots, it is either because some spots are superimposed on each other or because the coordinate for some spots does not fall completely on Spinda’s sprite.
To put them in place, the game adds 18 to the x-coordinate and 19 to the y-coordinate of the left face spot. It also adds 6 to the x-coordinate and 18 to the y-coordinate of the right face spot. Lastly, it adds 24 to the x-coordinate and 1 to the y-coordinate of of the left ear spot. The right ear spot’s coordinates are left unchanged.
Thus we have:
Code:
Left face spot upper-left hand coordinates: (23, 25)
Right face spot upper-left hand coordinates: (15, 22)
Left ear spot upper-left hand coordinates: (35, 3)
Right ear spot upper-left hand coordinates: (10, 13)
A new feature in Diamond and Pearl is the PokeRadar, which allows you to chain Pokemon. Chained Pokemon, besides having the advantage of always catching Pokemon of the same species, have a greater probability for them to appear shiny. This section explains in detail how the game determines whether or not a chained Pokemon is shiny, and how it constructs its PID so that it conforms to the criterion that appears in the previous section entitled ‘How the game makes a Pokemon shiny’.
7.1 The Probability of a Chained Pokemon to appear Shiny
This depends on the chain number you’ve attained, which cannot be greater than 40. Suppose your chain number is c. The probability that a chained Pokemon is shiny is governed by the following formula:
Code:
Probability = floor((14747 – 40 × c) ÷ (1640 – 40 × c)) ÷ 65536
where floor(x) is x rounded down.
Code:
Chain Length Probability of catching a Shiny Pokemon
0 1 in 8192
1 1 in 7282
2 1 in 7282
3 1 in 7282
4 1 in 7282
5 1 in 6554
6 1 in 6554
7 1 in 6554
8 1 in 6554
9 1 in 5958
10 1 in 5958
11 1 in 5958
12 1 in 5461
13 1 in 5461
14 1 in 5041
15 1 in 5041
16 1 in 4681
17 1 in 4681
18 1 in 4369
19 1 in 4369
20 1 in 4096
21 1 in 3855
22 1 in 3641
23 1 in 3449
24 1 in 3277
25 1 in 3121
26 1 in 2979
27 1 in 2731
28 1 in 2521
29 1 in 2341
30 1 in 2185
31 1 in 1986
32 1 in 1771
33 1 in 1598
34 1 in 1394
35 1 in 1192
36 1 in 993
37 1 in 799
38 1 in 596
39 1 in 400
40 or more 1 in 200
7.2 How the PID and IVs of a Chained Shiny Pokemon is created
First, the game calls the RNG twice to create the PID as usual. Remember that the first number generated would be the LID (last 16 bits) of the PID, while the second one would be the HID (first 16 bits) of the PID. The game now needs to ‘fix’ the PID such that the criterion for the Pokemon to appear shiny is attained. This is done as follows.
Convert the Trainer ID and Secret ID to binary, and look at their thirtheenth, twelfth, eleventh, etc. bits of both, until we reach their first bit. Suppose we’re looking at the i’th bit. For each of these pairs of bits, the RNG is called once and the resulting random number’s last bit is noted.
If the pair of bits at the i’th position of TID and SID are the same (i.e. either both are 0 or both are 1), the HID and LID’s i’th bits are both set to the last bit of the random number generated. If the pair of bits at the i’th position of TID and SID are different (i.e. one is 0 and the other one is 1), the LID’s i’th bit is set to the last bit of the random number generated, and the HID’s i’th bit is set to the reverse bit (1 if it was 0, 0 if it was 1) of the last bit of the random number generated.
Following this procedure, this would ensure that the number of 1’s in the i’th position of the TID, SID, HID and LID is either 0, 2 or 4. Since this would be true for all bits between the first and the thirteenth, the Pokemon would be ‘forced’ to appear shiny.
After this is done, there are two subsequent calls to the RNG to create the IVs as usual. Thus, the RNG is called 17 times in all to generate a chained shiny Pokemon: twice to generate the initial PID, 13 times to ‘fix’ the PID, and twice to generate the IVs.
7.3 An Example of generating the PID of a Chained Shiny Pokemon
Suppose the player encounters a chained shiny Pokemon. We suppose the player has Trainer ID (TID) 38710 and Secret ID (SID) 13099. We also suppose that the current RNG seed is [69AC550F]. We call the RNG twice, getting the numbers [18E5] and [1DD6]. Hence, the LID is [18E5] and the HID is [1DD6]. The numbers in binary are:
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: 0001110111010110
LID: 0001100011100101
We call the RNG, getting [A013]. When converted to binary, its last digit is 1. (To know at a glance if the last bit of a hexadecimal number is 0 or 1, look at the last hexadecimal digit. If it is 0, 2, 4, 6, 8, A, C or E, the last bit would be 0, otherwise it would be 1.)
The TID and SID’s thirteenth bits are 0 and 1 respectively, hence they are different. Thus, we make the thirteenth bit of LID as 1 (last digit of the last random number generated) and the first bit of HID as 0. So we have:
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: 000111011101[U]0[/U]110
LID: 000110001110[U]1[/U]101
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: 00011101110[U]10[/U]110
LID: 00011000111[U]01[/U]101
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: 0001110111[U]110[/U]110
LID: 0001100011[U]101[/U]101
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: 000111011[U]1110[/U]110
LID: 000110001[U]1101[/U]101
Code:
TID: 1001011100110110
SID: 0011001100101011
HID: [U]1100001101110[/U]110
LID: [U]0110011101101[/U]101
Ones: 2222024402422
Thus the PID of the chained shiny Pokemon would be
Code:
11000011011101100110011101101101