Author
Topic: Gender determination bug (Read 724 times)

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.

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

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.

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.

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.