Main Menu
Main Page
Forums
Recent changes
Random page
Help

Databases
GlitchDex
AttackDex
ItemDex
TrainerDex
TypeDex
UnownDex
More

Major Glitches
Trainer escape glitch
Old man trick
Celebi Egg trick
Select glitches (Japan)
SRAM glitch
CoolTrainer♀ corruption
LOL glitch
Rival LOL glitch
Super Glitch
ZZAZZ glitch
Pomeg corruption glitch (Glitzer Popping)
Tweaking
Elite Four door glitch (Japan)
Pokémon merge glitch
Pokémon cloning
Time Capsule exploit
Arbitrary code execution
Coin Case glitches
More

Other Glitch Categories
Glitches by generation
Glitches between two generations
Japan-only/language specific glitches
Music glitches
Natural glitches
Non-core series glitches
Non-Pokémon glitches
Officially acknowledged glitches
Recurring glitches
Dead glitches

References
Pokémon GameShark codes
The Big HEX List
Glitch Pokémon cries
GB programming
Curiosities
Debugging features
Easter eggs
Error traps
Glitch areas
Glitch myths
Non-glitch exploits
Placeholder texts
Pokémon glitch terminology
Unused content and prerelease information

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: Gender determination bug  (Read 606 times)

0 Members and 1 Guest are viewing this topic.

SnorlaxMonster

  • Member+
  • *
  • Offline Offline
  • Gender: Male
  • Probably on Bulbapedia
    • View Profile
Gender determination bug
« on: June 08, 2017, 11:45:07 am »
SciresM was looking into how gender is calculated in the Generation VII games, and discovered a bug in the algorithm (which also applies to the Generation VI games, which is why I posted it in this forum). For full details, see https://twitter.com/SciresM/with_replies

Note that unlike previous generations, from Generation VI onward gender is determined separately from PID. This is in contrast to previous generations, in which gender was a derived value from the PID, so Azurill could change genders upon evolution due to having a different gender ratio to Marill.

As I understand it, when a Gen VI or VII game generates a Pokemon, rather than simply generating a PID and then calculating the properties from there, it instead generates a value and determines the gender from that. In the case of gender, it's supposed to generate a value in the range [0,255], but instead generates one in the range [0,251]. The game also adds 1 before performing the comparison, so the range that is actually used is [1,252].

After taking this into account, these are the actual rates at which Pokémon will be each gender. (For 1:1, the off-by-one error and erroneous "greater than or equal" comparison actually cancels out the range error, giving the intended result.)

In Gen III to V, the genders are only skewed from their intended ratios by one, towards male (e.g. for 1:1 Pokémon, 129/256 are male and 127/256 are female). In Gen II, gender is actually calculated according to the proper ratios.
« Last Edit: June 22, 2017, 08:43:41 am by SnorlaxMonster »

Caveat

  • The Metropolitan Mutant of Ark
  • GCLF Member
  • *
  • Offline Offline
  • Wrrrooooooaaaar! Peeko!
    • View Profile
Re: Gender determination bug
« Reply #1 on: June 08, 2017, 12:20:27 pm »
The Azurill thing was great. I kinda wish they kept that in, somehow.

Anyway, is there any advantage towards generating the PID first?
HOLD ME, I'M A PALE MACHINE
LIFE IS JUST OKAY OUT HERE, ANYONE CAN SEE
I'M LONELY, WITH MY PALE MACHINE
EYES WILL RUN WITH TIRED TEARS, LIVING LIKE A DREAM


Japanese Glitchdex
Petscop Thread

Twitter
(warning: contains bad grammar and copious rambling)

SnorlaxMonster

  • Member+
  • *
  • Offline Offline
  • Gender: Male
  • Probably on Bulbapedia
    • View Profile
Re: Gender determination bug
« Reply #2 on: June 08, 2017, 10:21:11 pm »
Anyway, is there any advantage towards generating the PID first?
Well, it would stop the Gen VI-VII part of this bug from occurring. It's probably easier to implement Cute Charm encounters this way though (esp. after the Cure Charm exploit in Gen IV).
« Last Edit: June 08, 2017, 10:21:39 pm by SnorlaxMonster »

TheSixthItem

  • Game breaker
  • GCLF Member
  • *
  • Offline Offline
  • Gender: Male
  • ZZAZZDZZGZZUZZKZZ#ZZXZZUZZ7ZZ#ZZ
    • View Profile
Re: Gender determination bug
« Reply #3 on: June 22, 2017, 04:52:39 am »
Bulbapedia has it wrong, Pokemon.wikia has it wrong, SERIBII didn't even update all of them... We've got it all wrong... 11.9, not 12.5. It's pretty fucking stupid how we've taken this long to find out just a little bit of shitty coding. We've found so much about the red/blue code but sun/moon? We fucked up big time. There's apparently only one dataminer who even fucking cares about genders and we got this... That's bullshit
« Last Edit: June 22, 2017, 04:59:12 am by TheSixthItem »
I do things

ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Wiki Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
Re: Gender determination bug
« Reply #4 on: June 22, 2017, 06:56:45 am »
Every glitch matters. Sun and Moon are far less glitchy, and their code is way more complicated. Code analysis of R/B can be done by amateurs, but doing so for S/M requires professional tools and skill.
This is NOT bullshit. It's a bug, we study bugs, we write about this bug. It helps, for example, competitive players.
You never know when a bug may appear useful. That's why we track them all, and document them all.
"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 !)

Caveat

  • The Metropolitan Mutant of Ark
  • GCLF Member
  • *
  • Offline Offline
  • Wrrrooooooaaaar! Peeko!
    • View Profile
Re: Gender determination bug
« Reply #5 on: June 22, 2017, 07:54:21 am »
Bro, why are you so angry about a 0.6% difference in gender ratios?
HOLD ME, I'M A PALE MACHINE
LIFE IS JUST OKAY OUT HERE, ANYONE CAN SEE
I'M LONELY, WITH MY PALE MACHINE
EYES WILL RUN WITH TIRED TEARS, LIVING LIKE A DREAM


Japanese Glitchdex
Petscop Thread

Twitter
(warning: contains bad grammar and copious rambling)

SnorlaxMonster

  • Member+
  • *
  • Offline Offline
  • Gender: Male
  • Probably on Bulbapedia
    • View Profile
Re: Gender determination bug
« Reply #6 on: June 22, 2017, 08:47:47 am »
Bulbapedia has it wrong, Pokemon.wikia has it wrong, SERIBII didn't even update all of them... We've got it all wrong... 11.9, not 12.5. It's pretty fucking stupid how we've taken this long to find out just a little bit of shitty coding. We've found so much about the red/blue code but sun/moon? We fucked up big time. There's apparently only one dataminer who even fucking cares about genders and we got this... That's bullshit
I don't necessarily think this is a fair complaint. The nominal ratios are the ones worth noting in general, since they apply across generations. The skewing in Gen III-V (that also applies to Gen VI-VII) has been long documented, although noone noticed the new bug introduced in Gen VI.

For example, on Bulbapedia, the Pokemon pages list the nominal ratios (the only sensible thing to list), but the PID page explains how gender is actually calculated.

danny

  • Decamark Collector and Pokémaniac
  • Member+
  • *
  • Offline Offline
  • Gender: Male
  • i hate being alive
    • View Profile
Re: Gender determination bug
« Reply #7 on: June 23, 2017, 05:21:29 am »
Bulbapedia has it wrong, Pokemon.wikia has it wrong, SERIBII didn't even update all of them... We've got it all wrong... 11.9, not 12.5. It's pretty fucking stupid how we've taken this long to find out just a little bit of shitty coding. We've found so much about the red/blue code but sun/moon? We fucked up big time. There's apparently only one dataminer who even fucking cares about genders and we got this... That's bullshit
dude calm down

you could make this argument about that whole tentacool grass glitch in the spanish version of red and blue.
« Last Edit: June 23, 2017, 05:22:18 am by drc »
i ain't happy, i'm feeling glad
i got sunshine, in a bag
i'm useless, but not for long
my future is coming on

if you see any posts from around 2014-2016, please don't hold them against me in 2017 onwards.

my music