Gender determination bug
Posted by: SnorlaxMonster
Date: 2017-06-08 12:45:07
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.