Personality value: Difference between revisions

→‎Gender: https://pastebin.com/7jU5GRFE https://twitter.com/SciresM/status/872800978772393985 | Drawing a distinction between actual rate and nominal ratio
(→‎Gender: https://pastebin.com/7jU5GRFE https://twitter.com/SciresM/status/872800978772393985 | Drawing a distinction between actual rate and nominal ratio)
Line 54: Line 54:
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. 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♂}}.
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. With the exception of a few special cases, ''p<sub>gender</sub>'' is compared to the gender threshold to determine if the Pokémon is male or female.
 
If the gender threshold is not a special value (0, 254, or 255), ''p<sub>gender</sub>'' is compared to the gender threshold. If ''p<sub>gender</sub>'' is greater than or equal to the gender threshold, the Pokémon is male, otherwise it is 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. Additionally, in Generation VI and VII, due to multiple bugs in the implementation of the gender generation algorithm, ''p<sub>gender</sub>'' can only be between 1 and 252 (inclusive), which skews Pokémon towards the more common gender and makes certain personality values impossible.
 
If a species has a gender threshold of 255, it is genderless species (such as {{p|Magnemite}}), so is always genderless. If a species has a gender threshold of 254, it is a female-only species (such as {{p|Nidoran♀}}), so is always female. If a species has a gender threshold of 0, it is a male-only species (such as {{p|Nidoran♂}}), so is always male.


{| 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"
! colspan="2" | Gender threshold
! colspan="2" | Gender threshold
! colspan="2" | Gender ratio
! rowspan="2" | Nominal ratio<br>(♂:♀)
! colspan="2" | Frequency (Gen 3-5)
! colspan="2" | Frequency (Gen 6-7)
|-
|-
! Binary
! Binary
! Decimal
! Decimal
! Male
! Female
! Male
! Male
! Female
! Female
Line 67: Line 77:
| <code>11111111</code>
| <code>11111111</code>
| 255
| 255
| colspan="2" | Genderless
| Genderless
| colspan="4" | Genderless
|- style="background:#fff"
|- style="background:#fff"
| <code>11111110</code>
| <code>11111110</code>
| 254
| 254
| Female
| 0.0%
| 100.0%
| 0.0%
| 0.0%
| 100.0%
| 100.0%
|- style="background:#fff"
| <code>‭11011111‬</code>
| 223
| 1:7
| 13.3%
| 86.7%
| 11.1%
| 88.9%
|- style="background:#fff"
|- style="background:#fff"
| <code>10111111</code>
| <code>10111111</code>
| 191
| 191
| 25.0%
| 1:3
| 75.0%
| 25.8%
| 74.2%
| 24.6%
| 75.4%
|- style="background:#fff"
|- style="background:#fff"
| <code>01111111</code>
| <code>01111111</code>
| 127
| 127
| 1:1
| 50.4%
| 49.6%
| 50.0%
| 50.0%
| 50.0%
| 50.0%
Line 86: Line 114:
| <code>00111111</code>
| <code>00111111</code>
| 63
| 63
| 75.0%
| 3:1
| 25.0%
| 75.8%
| 24.2%
| 75.4%
| 24.6%
|- style="background:#fff"
|- style="background:#fff"
| <code>00011111</code>
| <code>00011111</code>
| 31
| 31
| 87.5%
| 7:1
| 12.5%
| 88.2%
| 11.7%
| 88.1%
| 11.9%
|- style="background:#fff"
|- style="background:#fff"
| <code>00000000</code>
| <code>00000000</code>
| 0
| 0
| Male
| 100.0%
| 0.0%
| 100.0%
| 100.0%
| 0.0%
| 0.0%
|}
|}
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.


===Ability===
===Ability===