Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation III Glitch Discussion

Possible Gen 3 Shiny Mismatch? - Page 1

Possible Gen 3 Shiny Mismatch?

Posted by: adamboy7
Date: 2020-04-23 23:04:24
Hello all. I've recently taken up a personal challenge to effectively generate shiny pokemon using the power of math, python, and bulbapedia. I am fully aware PKHex is a thing and I can just push the shiny button and be on my way, but where's the fun in that?

I wrote a program that takes in your ID, SID, and the personality value of your desired shiny-ified pokemon. It seems to be working great so far! So I decided to go a step further and see if I could brute force shiny PID's. It basically starts at PID of 0 , checks against your ID/SID, increments and repeats until it reaches the maximum value of 4294967295. Code found here, python 3:


Max = 4294967295
ID = 3020
SID = 39106
PID = 0
Shiny = 0

TID_XOR = ID ^ SID

list = open(str(ID) + " " + str(SID) + ".txt", "w")
list.write(str(ID) + " " + str(SID) + ":")

while PID <= Max:
    PID1 = int(bin(PID)[2:].zfill(32)[:16], 2)
    PID2 = int(bin(PID)[2:].zfill(32)[16:], 2)
    PID_XOR = PID1 ^ PID2
    if TID_XOR ^ PID_XOR <= 8:
        Shiny = Shiny + 1
        print (Shiny)
        list.write("\n" + hex(PID)[2:].zfill(8))
    PID = PID + 1
exit()


The game is Fire Red, my ID is 03020, my secret ID is 39106. Everything seems to have run correctly, I got 589824 shiny PID's. I tried a good number in PKHex and they're all shiny, with the exception of the first value it generated. Why isn't it shiny? The PID is 00009306 (Hex).

I did the math by hand and XORing everything works out to exactly 8 and should therefore be shiny. But neither in game nor in PKHex is my pokemon shiny. The math works out and it should be within hypothetical range of a valid PID, so why isn't it shiny? It's a silly thought experiment in the end anyways, but any insight is greatly appreciated. Thanks, Adam.

Math:

00000000000000001001001100000110 PID (37638)

0000101111001100 ID (3020)
1001100011000010 SID (39106)
1001001100001110 TID XOR (37646)

0000000000000000 PID1 (0)
1001001100000110 PID2 (37638)
1001001100000110 PID XOR (37638)

1001001100000110 PID XOR (37638)
1001001100001110 TID XOR (37646)
0000000000001000 Shiny Value (8)


Shiny Calculation from Bulbepedia:
https://bulbapedia.bulbagarden.net/wiki/Personality_value#Shininess

Link to my pk3 file:
http://www.mediafire.com/file/tdgrc9zmiviee3i/008_-_Larxene_-_61DB00009306.pk3/file

Link to my brute forced PID list:
http://www.mediafire.com/file/omzcmg22c9nuqqe/3020_39106.txt/file

Edit: Found the answer, it has to be less than 8, not less than or equal to for gen 3. My bad :P

Re: Possible Gen 3 Shiny Mismatch?

Posted by: CasualPokePlayer
Date: 2020-04-25 00:54:28

The game is Fire Red, my ID is 03020, my secret ID is 39106. Everything seems to have run correctly, I got 589824 shiny PID's. I tried a good number in PKHex and they're all Shiny, with the exception of the first value it generated. Why isn't it shiny? The PID is 00009306 (Hex).

I did the math by hand and XORing everything works out to exactly 8 and should therefore be shiny. But neither in game nor in PKHex is my pokemon shiny. The math works out and it should be within hypothetical range of a valid PID, so why isn't it shiny? It's a silly thought experiment in the end anyways, but any insight is greatly appreciated. Thanks, Adam.


According to Bulbapedia: "From Generation III to V, if S < 8, the Pokémon is Shiny."

8 is not less than 8 lol

EDIT: Also, a really easy way to get a shiny PID is to just take the Secret ID, make it the top 16 bits of the PID, then take the TID, and make it the bottom 16 bits, and boom shiny PID :P

Re: Possible Gen 3 Shiny Mismatch?

Posted by: adamboy7
Date: 2020-04-25 14:01:11
Okay, I feel silly now  :XD: Thanks for pointing that out CasualPokePlayer, that means my brute force is only viable in generation 6+. That means I need to just replace <= with just <.

Also, thanks for the tip, I'll add it to the list. I have the option to remove this post, and maybe I should since it's not actually a glitch? I dunno, there's some good math in here, maybe someone will find it useful. If a mod wants to delete it, go for it.