Personality value: Difference between revisions

m
→‎Gender: Psuedo-code can be just as if not more confusing to the average person. The solution is to improve the part that was actually confusing
(The description of the determination of gender is somewhat confusing, so I added a pseudocode description of the algorithm.)
m (→‎Gender: Psuedo-code can be just as if not more confusing to the average person. The solution is to improve the part that was actually confusing)
Line 6: Line 6:
A Pokémon's [[gender]] is determined by the lowest eight digits (the lowest byte, highlighted in <span style="background:#FF9999">red</span> above) of ''p'' in binary form. Mathematically, this can be derived by calculating <code>''p'' [[wp:modulo operation|%]] 256</code>. Below, this value will be referred to as ''p<sub>gender</sub>''.
A Pokémon's [[gender]] is determined by the lowest eight digits (the lowest byte, highlighted in <span style="background:#FF9999">red</span> above) of ''p'' in binary form. Mathematically, this can be derived by calculating <code>''p'' [[wp:modulo operation|%]] 256</code>. Below, this value will be referred to as ''p<sub>gender</sub>''.


In a Pokémon species' [[Pokémon base stats data structure in Generation III|base stat structure]], there is a value called the ''gender threshold'', a byte with a value ranging from 0 to 255. Genderless species of Pokémon such as {{p|Magnemite}} have a value of 255 for their gender threshold. Female-only species such as {{p|Nidoran♀}} have a value of 254 for their gender threshold, while for male only species such as {{p|Nidoran♂}} the value is 0. The remaining values describe Pokémon with both genders: if ''p<sub>gender</sub>'' is greater than or equal to the gender threshold, the Pokémon is male; otherwise it is female.
In a Pokémon species' [[Pokémon base stats data structure in Generation III|base stat structure]], there is a value called the ''gender threshold'', a byte with a value ranging from 0 to 255. In most cases, if ''p<sub>gender</sub>'' is greater than or equal to the gender threshold, the Pokémon is male, otherwise it is female. There are a few special values for the gender threshold, however, that are interpreted specially and without regard to the value of ''p<sub>gender</sub>''. A gender threshold of 255 indicates genderless species of Pokémon such as {{p|Magnemite}}. The value 254 indicates female-only species such as {{p|Nidoran♀}}. Finally, the value 0 indicates male-only species such as {{p|Nidoran♂}}.


{| class="roundy" style="text-align:center; background: #C0C0FF; border: 3px solid blue; margin-bottom: 10px"
{| class="roundy" style="text-align:center; background: #C0C0FF; border: 3px solid blue; margin-bottom: 10px"
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==