Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle overflows while tempering #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bhamrick
Copy link

This appears to be the cause of the various incorrect results. When self.state[0] + (self.state[2] >> 8) is larger than 2^32, the python code here includes that 2^32 bit in the output while the corresponding C code implicitly removes it. Because the moduli used are often not powers of 2, this can cause incorrect natures, incorrect inheritance, etc. If it occurred during the rejection sampling for inherited IVs, it could cause fewer or extra rerolls, leading to incorrect directions to acquire the desired egg.

Here's a case for reproducing the bug:
seed: 17a56a9e f58f35a0 8880cfc0 2963762f
male is ditto, 1-1 gender ratio, no items
The resulting egg should be
Relaxed, Male, HP from male, 3 Atk, 5 Def, SpA from female, 30 SpD, Spe from female

This appears to be the cause of the various incorrect results. When `self.state[0] + (self.state[2] >> 8)` is larger than 2^32, the python code here includes that 2^32 bit in the output while the corresponding C code implicitly removes it. Because the moduli used are often not powers of 2, this can cause incorrect natures, incorrect inheritance, etc. If it occurred during the rejection sampling for inherited IVs, it could cause fewer or extra rerolls, leading to incorrect directions to acquire the desired egg.

Here's a case for reproducing the bug:
seed: 17a56a9e f58f35a0 8880cfc0 2963762f
male is ditto, 1-1 gender ratio, no items
The resulting egg should be
Relaxed, Male, HP from male, 3 Atk, 5 Def, SpA from female, 30 SpD, Spe from female
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant