From b8a799f7ed481f0ebbb66617c89f4741cccff212 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 23 May 2017 18:48:16 -0700 Subject: [PATCH] Fix gender ratio comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://bulbapedia.bulbagarden.net/wiki/Personality_value#Gender For a Pokémon with a 50/50 male/female gender ratio, there is actually a 129/256 (50.390625%) chance for the Pokémon to be male and 127/256 (49.609375%) chance for the Pokémon to be female. remove unnecessary parameter passing #1163 --- PKHeX.Core/PKM/PKM.cs | 2 +- PKHeX.Core/PKM/PKX.cs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 81a683eea..e782b04b7 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -585,7 +585,7 @@ public virtual bool getGenderIsValid() if (GenNumber >= 6) return true; - return gender == PKX.getGender(Species, PID, gv); + return gender == PKX.getGender(PID, gv); } /// diff --git a/PKHeX.Core/PKM/PKX.cs b/PKHeX.Core/PKM/PKX.cs index 8a23cc622..06cd4e469 100644 --- a/PKHeX.Core/PKM/PKX.cs +++ b/PKHeX.Core/PKM/PKX.cs @@ -474,7 +474,7 @@ public static uint getRandomPID(int species, int cg, int origin, int nature, int return pid; // PID can be anything // Gen 3/4/5: Gender derived from PID - if (cg == getGender(species, pid, gt)) + if (cg == getGender(pid, gt)) return pid; } } @@ -1408,17 +1408,16 @@ public static int getG3Species(int g4index) public static int getGender(int species, uint PID) { int genderratio = Personal[species].Gender; - return getGender(species, PID, genderratio); + return getGender(PID, genderratio); } - public static int getGender(int species, uint PID, int gv) + public static int getGender(uint PID, int gr) { - int genderratio = Personal[species].Gender; - switch (genderratio) + switch (gr) { case 255: return 2; case 254: return 1; case 0: return 0; - default: return (PID & 0xFF) <= genderratio ? 1 : 0; + default: return (PID & 0xFF) < gr ? 1 : 0; } } #region Gen 3 Species Table