Personality value: Difference between revisions

The description of the determination of gender is somewhat confusing, so I added a pseudocode description of the algorithm.
(→‎Size: Fixed copy/format error on p2 in first calculation)
(The description of the determination of gender is somewhat confusing, so I added a pseudocode description of the algorithm.)
Line 58: Line 58:


Because the comparison to determine gender is greater than or equal, Pokémon are not actually perfectly distributed between male and female according to the ideal ratios shown above. For example, 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.
Because the comparison to determine gender is greater than or equal, Pokémon are not actually perfectly distributed between male and female according to the ideal ratios shown above. For example, 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.
=== Algorithm ===
procedure {{tt|gender|Returns the gender of a Pokémon; one of either MALE, FEMALE, or GENDERLESS.}}({{tt|p_value|The personality value of the Pokémon.}}, {{tt|threshold|The gender threshold for the Pokémon's species.}}):
  if threshold = 255: return GENDERLESS
  if threshold = 254: return FEMALE
  p_gender := p_value & 0xFF
  if p_gender < threshold: return FEMALE
  else: return MALE


==Ability==
==Ability==
317

edits