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

Super Metroid: Replace random module with world random in variaRandomizer #4429

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

Conversation

Mysteryem
Copy link
Contributor

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 the random argument is more like a self 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 the random 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.

…izer

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 the `random` argument is more like a `self` argument in a method.

The multiworld seed is now passed through to variaRandomizer instead of
it generating its own seed.
@github-actions github-actions bot added the waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. label Jan 3, 2025
@PoryGone PoryGone added the waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world. label Jan 3, 2025
@PoryGone
Copy link
Collaborator

PoryGone commented Jan 3, 2025

@lordlou

@Exempt-Medic Exempt-Medic added is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. is: refactor/cleanup Improvements to code/output readability or organizization. labels Jan 5, 2025
@Exempt-Medic
Copy link
Member

This has conflicts btw

@Exempt-Medic Exempt-Medic added the waiting-on: author Issue/PR is waiting for feedback or changes from its author. label Jan 13, 2025
…ndom

# Conflicts:
#	worlds/sm/variaRandomizer/randomizer.py
@Exempt-Medic Exempt-Medic removed the waiting-on: author Issue/PR is waiting for feedback or changes from its author. label Jan 14, 2025
Copy link
Contributor

@lordlou lordlou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@Exempt-Medic Exempt-Medic removed the waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world. label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. is: refactor/cleanup Improvements to code/output readability or organizization. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants