Properly handle overflows while tempering #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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