LaprasBoi said:
Um. Does this actually happen? I mean, YES, the gender ratios are different, and based on that I knew which answer you wanted, but it’s not like a Pokémon’s gender is randomly recalculated based on ratio every time one evolves. This would have to be specially written code applying only to Azurill->Marill evolutions. Does that really exist? I am willing to acknowledge that it is possible, since other Pokémon have weird little bits of code that apply only to them( like Wurmple, Spinda, etc.), but I definitely had never heard of this one before. Have you ever had a female Azurill change genders when you evolved it? Assuming for a moment that this does really happen, is it determined when the Egg is created? Or can you save before your Azurill evolves and reset to ensure that she does/doesn’t change gender according to your preference? And where did you hear that this was based on marine life?
It's because of how the game determines a Pokemon's gender. How it does so, is it generates a random number between 1 and 256 for it right when you encounter a Pokemon/the egg forms at the Daycare. Where this number falls, with respect to the Pokemon's gender ratio, determines its gender.
For example, a Pokemon has a 50% Female, 50% Male ratio. What would happen in that scenario would be that all numbers from 1-128 would result in Female and 129-256 would result in male (but I might have it reversed). So, if the random number generator ends up with 129, the Pokemon would be male.
That number (the output from the RNG) never changes. However, the ratio can change, as with Azurill and Marill, which can result in a change in the gender.
To explain this, let's say that 50-50 ratio Pokemon then evolves into a Pokemon with a 75% Female and 25% Male ratio. Now results from 1-192 (First 75% of 256) would result in female, with 193-256 (Last 25% of 256) resulting in male. Since the number the RNG selected doesn't change, the Pokemon's gender-determining number is still 129. But since a 129 is now in the Pokemon's female-gender range, the Pokemon ends up switching gender to female.
This also isn't something that needs to be programmed exclusively for Marill; the game runs a check for this sort of stuff when a Pokemon evolves, regardless of what it is. It's just with Azumarill and Marill, there's an actual chance of the gender changing due to the different ratios, whereas with other Pokemon, the ratios are constant so the check on them won't ever result in a change in gender.