# 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 VI Glitch Discussion

### Gender determination bug - Page 1

Previous Page

- 1

Next Page

#### Gender determination bug

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

#### Re: Gender determination bug

Posted by: Caveat
Date: 2017-06-08 13:20:27
The Azurill thing was great. I kinda wish they kept that in, somehow.
Anyway, is there any advantage towards generating the PID first?

#### Re: Gender determination bug

Posted by: SnorlaxMonster
Date: 2017-06-08 23:21:11

> 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).

#### Re: Gender determination bug

Posted by: TheSixthItem
Date: 2017-06-22 05:52:39
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

#### Re: Gender determination bug

Posted by: ISSOtm
Date: 2017-06-22 07:56:45
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.

#### Re: Gender determination bug

Posted by: Caveat
Date: 2017-06-22 08:54:21
Bro, why are you so angry about a 0.6% difference in gender ratios?

#### Re: Gender determination bug

Posted by: SnorlaxMonster
Date: 2017-06-22 09:47:47

> 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.

#### Re: Gender determination bug

Posted by: Spoink
Date: 2017-06-23 06:21:29

> 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.

#### Re: Gender determination bug

Posted by: Duelist Of Roses
Date: 2018-06-30 17:28:04

> 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.

You really love bug-type pokemon don't you? XD

#### Re: Gender determination bug

Posted by: Duelist Of Roses
Date: 2018-06-30 17:30:18

> > 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.

What is wrong with Jellyfish in grass? I have seen plenty dead sea creatures rotting in the sun covered by tall grass. #Depressing

#### Re: Gender determination bug

Posted by: ISSOtm
Date: 2018-07-01 06:46:16
Adding to "please don't bump threads": do not double-post, either. Again, please read the forum rules.

#### Re: Gender determination bug

Posted by: Zowayix
Date: 2018-07-18 22:04:07
It's okay, I had glitched out gender values when I was generated too
Previous Page

- 1

Next Page