Main Menu
Main Page
Forums
Recent changes
Random page
Help

Databases
GlitchDex
AttackDex
AreaDex
DexDex
ItemDex
MetascriptDex
TMHMDex
TrainerDex
TypeDex
UnownDex
More

Major Glitches
Trainer escape glitch
Old man glitch
Celebi Egg glitch
SRAM glitch
Buffer overflow techniques
Pomeg glitch data corruption (Glitzer Popping)
Tweaking
Pokémon cloning
Select glitches (Japan)
Time Capsule exploit
Arbitrary code execution
More

Other Glitch Categories
Glitches by generation
Japan-only/language specific glitches
Natural glitches
Non-core series glitches
Non-Pokémon glitches
Recurring glitches
More

References
Pokémon GameShark codes
Pokémon Game Genie codes
Disassembly projects
The Big HEX List
GB programming
Curiosities
Debugging features
Error traps
Non-glitch exploits
Pokémon glitch terminology
Unused content and prerelease information
More

Useful Tools
8F Helper
GBz80 to Items
Old man trick name generator
PATH (Prama's Advanced Tweaking Heaven)
Save file editors
Special stat/Pokémon converter
Trainer escape Trainer Pokémon finder

Affiliates
Legendary Star Blob 2 (Hakuda)
Pokémon Speedruns wiki
PRAMA Initiative
Become an affiliate!

Technical
Site Source Code

Search Wiki

 

Search Forums

 

Author Topic: Does anyone know the probability of this?  (Read 372 times)

0 Members and 1 Guest are viewing this topic.

Nostalgia

  • GCLF Member
  • *
  • Offline Offline
  • Gender: Male
  • ?
    • View Profile
Does anyone know the probability of this?
« on: September 15, 2018, 11:04:04 am »
I just got a trainer ID of 22222. I'm trying to work out the probability of this occurring because it seems it's not as simple as the probability of the same five digits occurring - because the highest trainer ID you can get is 65535. So you can't get for example a trainer ID number starting in 9.

Also this in a third gen game and I know Pokemon games starting from Generation VII have six digit trainer ID's now.
 
I was just wondering if anyone might know the answer.  :)   

IceFlame

  • GCLF Member
  • Offline Offline
  • Gender: Female
    • View Profile
Re: Does anyone know the probability of this?
« Reply #1 on: September 15, 2018, 11:16:08 am »
If it goes from 0 to 65535, and you're looking for 00000,11111..55555, that would be 6/65536 or just under 1 in 10000.

Evie Torchic the Glitch Scientist

  • Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • Thank you for this lovely artwork Nyapon!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #2 on: September 15, 2018, 11:23:15 am »
If it goes from 0 to 65535, and you're looking for 00000,11111..55555, that would be 6/65536 or just under 1 in 10000.

This.

At a first look it might be simply be (theoretical odds) 1/65536 for any combination (the same chance as any ID such as say 12345 or 49120), and like IceFlame said if you want 5 of the same digits it would be 5/65536 (note IceFlame you forgot you can't get 66666 in Generation III) but with any pseudo-random number generator the 'experimental odds' might be a little different (not sure to what extent), especially Emerald with its broken RNG.
Hi!

I'm Evie.

I'm a transgender person, but any pronouns are fine. She/her preferred.

Unfortunately due to legal concerns I won't be using emulators and unauthorised copies of ROMs anymore, just real hardware with official cartridges and a cheating device (Xploder) to aid research, sorry.

Online I most often use the username Torchickens or Chickasaurus.

Ah.. koucha ga oishii ♪





Thanks Aeriixion for the cute sprite above! :) Roelof also made different variations of the sprite (which I animated).




Contact:
If you like, please contact me by private message here on the forums as I no longer check other places very often.

YouTube: http://www.youtube.com/user/ChickasaurusGL

I like to collect interesting video games. ^_^
https://www.vgcollect.com/Torchickens

To love yourself is to believe in yourself, respect yourself, but to make allowances for weakness. If you do the same with others in need (believing in them), in keeping an open mind and being modest, then it will not only help each other but can make life more meaningful. The heart though, has no script, and true wisdom may not exist; often ignorance can give us bliss and the darker times enlighten us later on.

IceFlame

  • GCLF Member
  • Offline Offline
  • Gender: Female
    • View Profile
Re: Does anyone know the probability of this?
« Reply #3 on: September 15, 2018, 11:35:44 am »
I wasn't counting 66666, but I counted 00000 - is that one possible?

Sherkel

  • λP[ιx(P(x))](λy[OF(y,finnegan)](λz[PFTJSCHUTE(z)]))
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Gehen wir mit die Sonne spazieren!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #4 on: September 15, 2018, 12:22:21 pm »
Yep, I've gotten 00000 before, so it's 6/65536. This is especially lucky in FireRed, LeafGreen, or Emerald, as you can't manipulate your ID in those (unless you run a script to keep loading a state before you confirm your name).
 

Evie Torchic the Glitch Scientist

  • Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • Thank you for this lovely artwork Nyapon!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #5 on: September 15, 2018, 01:19:13 pm »
I wasn't counting 66666, but I counted 00000 - is that one possible?

Oops, my mistake. :( Yeah, I forgot about the 00000 one. Sorry for my carelessness.

This is especially lucky in FireRed, LeafGreen, or Emerald, as you can't manipulate your ID in those (unless you run a script to keep loading a state before you confirm your name).

Ah OK. Interesting!
Hi!

I'm Evie.

I'm a transgender person, but any pronouns are fine. She/her preferred.

Unfortunately due to legal concerns I won't be using emulators and unauthorised copies of ROMs anymore, just real hardware with official cartridges and a cheating device (Xploder) to aid research, sorry.

Online I most often use the username Torchickens or Chickasaurus.

Ah.. koucha ga oishii ♪





Thanks Aeriixion for the cute sprite above! :) Roelof also made different variations of the sprite (which I animated).




Contact:
If you like, please contact me by private message here on the forums as I no longer check other places very often.

YouTube: http://www.youtube.com/user/ChickasaurusGL

I like to collect interesting video games. ^_^
https://www.vgcollect.com/Torchickens

To love yourself is to believe in yourself, respect yourself, but to make allowances for weakness. If you do the same with others in need (believing in them), in keeping an open mind and being modest, then it will not only help each other but can make life more meaningful. The heart though, has no script, and true wisdom may not exist; often ignorance can give us bliss and the darker times enlighten us later on.

Nostalgia

  • GCLF Member
  • *
  • Offline Offline
  • Gender: Male
  • ?
    • View Profile
Re: Does anyone know the probability of this?
« Reply #6 on: September 15, 2018, 02:02:24 pm »
If it goes from 0 to 65535, and you're looking for 00000,11111..55555, that would be 6/65536 or just under 1 in 10000.


Less chance than encountering a shiny Pokemon. Nice. Though 55555 would have been better. ;D

Yep, I've gotten 00000 before, so it's 6/65536. This is especially lucky in FireRed, LeafGreen, or Emerald, as you can't manipulate your ID in those (unless you run a script to keep loading a state before you confirm your name).

Yes it's FireRed. I've always like cool trainer ID's so I reset for them. I know some shiny hunters do it as well because they seem to think having a patterned trainer ID makes them more lucky lol. I just like them because they look neat and the ID stays with you for the rest of the game and it's attached to every Pokemon to catch or breed so having something unique looks better than something really generic like 01493. I wasn't sure whether to keep this one though because I usually only like ones that start with 5 or 6, but given how lucky this is I'll keep it.

ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
Re: Does anyone know the probability of this?
« Reply #7 on: September 15, 2018, 08:17:02 pm »
I've had to manipulate my TID in Red to test SGB boot ROM durations (the boot ROM forwards the whole ROM header to the SNES, which may or may not stop clocking the CPU; however, the code paths between sending a 1 bit and a 0 bit differ by 1 M-cycle, which further bleeds into a LY waitloop... It's a mess to emulate accurately :')
Procedure:
1. Let intro play out
2. While game title is sliding in, hold START
3. During blank screen, release START and hold A
4. There you go, TID 0880something, 100% consistent :) (Only tested on a French version. Would differ with other ROMs, since they have a different header -- any alteration to the ROM alters the global checksum as well, which alters the SGB boot timing..!)
"THOU SHALL NOT PASS !!"  RIVAL's effect, Gandalf.

Proudly glitching Pokémon Red and Yellow on a Black & White GB, Pocket GB, GB Color, GBA SP and new 3DS.

My Twitter (beware, I'm French)
My YouTube (same warning)

Here is an online tool to build 8F setups : GBz80 to Items !

They see me layzin', they ha-tin'...
Heavy contributor of the global augmentation of entropy (my room's is too damn high !)

Sherkel

  • λP[ιx(P(x))](λy[OF(y,finnegan)](λz[PFTJSCHUTE(z)]))
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Gehen wir mit die Sonne spazieren!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #8 on: September 15, 2018, 08:56:19 pm »
I guess it's my turn for a "Chickasaurus moment" because I want to hammer down how lucky this is and need to calm down anyway.

The GBA has an internal timer that increments by 1 every CPU cycle, which is about 59.59 nanoseconds or 16.8 million (2^24) increments per second. Most games don't bother to use this, and instead opt to time things by incrementing by 1 every time the screen is refreshed (VBlank), which is about 60 times per second or one frame. In Gen III, these frames are the exact same "frames" used in players' RNG calculations. This is because nearly every RNG operation done by the game is done using the current value in memory that changes every frame through a linear congruential algorithm (multiply by some set number then add some set number,) a very primitive way of creating "random" numbers (not that they ever expected anyone to bother to figure it out). This value (the seed) starts at 0 in Emerald, and 5A0 in Ruby or Sapphire with a dead battery. In FireRed, LeafGreen, and live battery Ruby and Sapphire, there's an unpredictable algorithm run on startup that determines the starting value, which means you're screwed for RNGing on a physical copy of those. The LCG is arguably less "primitive" in that it ends up allowing every possible 32-bit value to occupy that memory location, still less than the amount of possible IV/nature combinations, but enough that most wouldn't care. 524288 of these values (2^32 / 8192) result in shiny Pokémon, as that many return "true" when put through an algorithm using both your ID and secret ID as variables (simplifying a lot here, but it's not the main focus anyway.)

So we have frames, and we have the GBA's internal timer. The 60 Hz timer for RNG was mostly retired in Gen IV (initial seed generation aside), was completely nonexistent in Gen V unless you were in the Entralink, has an unknown function in Gen VI, and finally returned in Gen VII. In Gen III, it still determined everything, except for one thing...IDs in FireRed, LeafGreen, and Emerald. These used the 16.8 MHz timer, which I'm guessing VBA stumbles with now and then, making these nice save files technically legal hacks:




(had to bite the bullet with VBA in order to run the script I mentioned a few posts above)

Odder yet, the secret ID is generated by using the value that changes with every increment on the 60 Hz timer! Odder again, the value in question is rewritten when the normal ID is generated, making these also impossible to manipulate without an emulator! I can't come up with any explanation for this other than:



So yeah, a vanity ID on a physical copy of one of these games...kind of a big deal. ;D

(In Ruby and Sapphire, the ID is determined from the upper 16 bits of the seed at the end of the Birch intro, and then the LCG is incremented by 2 and the upper 16 bits of that are used to determine the secret ID. So in those, you can't get the shiny IVs you want with just any visible ID, because it's tied directly to the secret one.)

And yeah, Gen I ID abuse is fairly easy but also very limited with how much you can reliably get. It's a must for any sort of glitched run, though, because that value factors into ACE. It's the reason the rules have become so much more strict ever since those games' RNG was cracked; prior to its discovery, nothing emulated it properly, and now there's just one emulator that does, plus all the values Isso mentioned that one has to take into account.
« Last Edit: September 15, 2018, 09:09:14 pm by Sherkel »
 

Nostalgia

  • GCLF Member
  • *
  • Offline Offline
  • Gender: Male
  • ?
    • View Profile
Re: Does anyone know the probability of this?
« Reply #9 on: September 16, 2018, 05:39:50 am »
In FireRed, LeafGreen, and live battery Ruby and Sapphire, there's an unpredictable algorithm run on startup that determines the starting value, which means you're screwed for RNGing on a physical copy of those.

I've never tried RNGing anyway and I don't completely understand how to do it and I assume it's harder to do on a real copy compared to a ROM. I've read it's supposedly very effective to do in Emerald, but its not hard to breed Pokemon with good IV's. RNGing for a perfect Pokemon doesn't seem fun anyway. I do however like soft resetting for good natures/IV's.

Thanks for all the info though. That's exactly why I asked this question because I know there are much more knowledgeable members on this forum than me when it comes to the inner workings of the games.

So yeah, a vanity ID on a physical copy of one of these games...kind of a big deal. ;D

I only play on physical copies, never ROM's, so this is good to hear. :D

And yeah, Gen I ID abuse is fairly easy but also very limited with how much you can reliably get. It's a must for any sort of glitched run, though, because that value factors into ACE. It's the reason the rules have become so much more strict ever since those games' RNG was cracked; prior to its discovery, nothing emulated it properly, and now there's just one emulator that does, plus all the values Isso mentioned that one has to take into account.

I just used ws m in Yellow and coin case/bad clone ACE in Gold/Crystal to change my ID easily. I remember Torchickens had to help me with Yellow.  8)

Sherkel

  • λP[ιx(P(x))](λy[OF(y,finnegan)](λz[PFTJSCHUTE(z)]))
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Gehen wir mit die Sonne spazieren!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #10 on: September 16, 2018, 07:50:31 am »
The main point is that an ID in FireRed is determined by timing of one 16 millionth of a second as opposed to one 60th of a second in games like Ruby or one 30th in ones like Diamond and HeartGold. Hitting A in a 59 nanosecond interval is humanly impossible.

ACE is the surefire way to a specific ID in Gens I/II, no doubt. I was just referring to their initial generation after hitting "New Game".

Looking it back over now, I left out a lot, and also included a lot of unnecessary info, but oh well, it seems like I answered whatever questions you may have had. :) Glad to help.
 

Evie Torchic the Glitch Scientist

  • Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • Thank you for this lovely artwork Nyapon!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #11 on: September 17, 2018, 08:44:22 am »
I guess it's my turn for a "Chickasaurus moment" because I want to hammer down how lucky this is and need to calm down anyway.

The GBA has an internal timer that increments by 1 every CPU cycle, which is about 59.59 nanoseconds or 16.8 million (2^24) increments per second. Most games don't bother to use this, and instead opt to time things by incrementing by 1 every time the screen is refreshed (VBlank), which is about 60 times per second or one frame. In Gen III, these frames are the exact same "frames" used in players' RNG calculations. This is because nearly every RNG operation done by the game is done using the current value in memory that changes every frame through a linear congruential algorithm (multiply by some set number then add some set number,) a very primitive way of creating "random" numbers (not that they ever expected anyone to bother to figure it out). This value (the seed) starts at 0 in Emerald, and 5A0 in Ruby or Sapphire with a dead battery. In FireRed, LeafGreen, and live battery Ruby and Sapphire, there's an unpredictable algorithm run on startup that determines the starting value, which means you're screwed for RNGing on a physical copy of those. The LCG is arguably less "primitive" in that it ends up allowing every possible 32-bit value to occupy that memory location, still less than the amount of possible IV/nature combinations, but enough that most wouldn't care. 524288 of these values (2^32 / 8192) result in shiny Pokémon, as that many return "true" when put through an algorithm using both your ID and secret ID as variables (simplifying a lot here, but it's not the main focus anyway.)

So we have frames, and we have the GBA's internal timer. The 60 Hz timer for RNG was mostly retired in Gen IV (initial seed generation aside), was completely nonexistent in Gen V unless you were in the Entralink, has an unknown function in Gen VI, and finally returned in Gen VII. In Gen III, it still determined everything, except for one thing...IDs in FireRed, LeafGreen, and Emerald. These used the 16.8 MHz timer, which I'm guessing VBA stumbles with now and then, making these nice save files technically legal hacks:




(had to bite the bullet with VBA in order to run the script I mentioned a few posts above)

Odder yet, the secret ID is generated by using the value that changes with every increment on the 60 Hz timer! Odder again, the value in question is rewritten when the normal ID is generated, making these also impossible to manipulate without an emulator! I can't come up with any explanation for this other than:



So yeah, a vanity ID on a physical copy of one of these games...kind of a big deal. ;D

(In Ruby and Sapphire, the ID is determined from the upper 16 bits of the seed at the end of the Birch intro, and then the LCG is incremented by 2 and the upper 16 bits of that are used to determine the secret ID. So in those, you can't get the shiny IVs you want with just any visible ID, because it's tied directly to the secret one.)

And yeah, Gen I ID abuse is fairly easy but also very limited with how much you can reliably get. It's a must for any sort of glitched run, though, because that value factors into ACE. It's the reason the rules have become so much more strict ever since those games' RNG was cracked; prior to its discovery, nothing emulated it properly, and now there's just one emulator that does, plus all the values Isso mentioned that one has to take into account.

Really interesting!

Also thanks, you flatter me.

I remember reading that luck on certain Game Boy (DMG/GBC) emulators isn't too accurate either, which is why many speedrunners only accept real hardware or more accurate ones for RNG abuse. Additionally is it true VisualBoyAdvance may have less frames per second than real hardware? I think this was mentioned on TASVideos Forums regarding the bad clone glitch somewhere.
« Last Edit: September 17, 2018, 08:44:57 am by Evie Torchic the Glitch Scientist »
Hi!

I'm Evie.

I'm a transgender person, but any pronouns are fine. She/her preferred.

Unfortunately due to legal concerns I won't be using emulators and unauthorised copies of ROMs anymore, just real hardware with official cartridges and a cheating device (Xploder) to aid research, sorry.

Online I most often use the username Torchickens or Chickasaurus.

Ah.. koucha ga oishii ♪





Thanks Aeriixion for the cute sprite above! :) Roelof also made different variations of the sprite (which I animated).




Contact:
If you like, please contact me by private message here on the forums as I no longer check other places very often.

YouTube: http://www.youtube.com/user/ChickasaurusGL

I like to collect interesting video games. ^_^
https://www.vgcollect.com/Torchickens

To love yourself is to believe in yourself, respect yourself, but to make allowances for weakness. If you do the same with others in need (believing in them), in keeping an open mind and being modest, then it will not only help each other but can make life more meaningful. The heart though, has no script, and true wisdom may not exist; often ignorance can give us bliss and the darker times enlighten us later on.

Sherkel

  • λP[ιx(P(x))](λy[OF(y,finnegan)](λz[PFTJSCHUTE(z)]))
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Gehen wir mit die Sonne spazieren!
    • View Profile
Re: Does anyone know the probability of this?
« Reply #12 on: September 17, 2018, 11:00:55 am »
Gambatte-Speedrun was a fork specifically created to emulate RBY's RNG correctly, and I think BGB got an update soon afterward to do the same. The reason it may have taken so long to get around to emulating correctly is that it has to do with instructions passed from the GBC's BIOS to the ROM, not just instructions in the ROM itself. I wouldn't be surprised if everything besides the initial seeding process worked correctly in versions before the update.

As for VBA, I don't know exactly, but I'm pretty sure if you left it open with a timer at the same time as a physical GBA, it would at least be off by more than one 16 millionth of a second.

Buuuut I don't care. :P I still moved one of those saves to a real Emerald cartridge and have shinies from it on my physical copy of Ultra Moon.
« Last Edit: September 17, 2018, 11:04:18 am by Sherkel »
 

ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Staff
  • *****
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
Re: Does anyone know the probability of this?
« Reply #13 on: September 17, 2018, 01:36:59 pm »
Yeah, RBY's RNG runs off of DIV, which counts starting from the boot ROM.
"THOU SHALL NOT PASS !!"  RIVAL's effect, Gandalf.

Proudly glitching Pokémon Red and Yellow on a Black & White GB, Pocket GB, GB Color, GBA SP and new 3DS.

My Twitter (beware, I'm French)
My YouTube (same warning)

Here is an online tool to build 8F setups : GBz80 to Items !

They see me layzin', they ha-tin'...
Heavy contributor of the global augmentation of entropy (my room's is too damn high !)