Super Metroid: Replace random module with world random in variaRandomizer #4429
+150
−138
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.
What is this fixing or adding?
Replaces direct use of the
random
module with passing around the world's.random
attribute instead.Fixes different generation on webhost compared to local generation, assuming no yaml options are using random options because all random option resolution is currently nondeterministic on webhost.
The new arguments for passing self.random through to the various variaRandomizer classes and functions have been added to the end of the arguments for each relevant function, except
utils.randGaussBounds
where therandom
argument is more like aself
argument in a method, so has been added as the first argument instead.The multiworld seed is now passed through to variaRandomizer instead of it generating its own seed.
How was this tested?
I started by removing all the
random
module imports and ran many generations with 5 almost fully random yamls, making adjustments to pass through the world's.random
whenever generation crashed because it was trying to access therandom
module still. This helped me see the function calls through the code to determine what classes and functions I would have to pass the world's.random
through.Once generation was succeeding and I could not find any more direct use of the
random
module, I ran a generation of the template yaml on archipelago.gg (specifically the template yaml has no options set to random so should generate deterministically) and generated with the same seed locally and determined them to now produce the same results.Additionally, I ran these changes along with the WIP test in #4410, and the failing test for Super Metroid would now pass.
I have not done any tests that go as far as connecting the client to a multiworld and patching the ROM, so I recommend more testing should be done by people more familiar with Super Metroid AP.