Skip to content

SMZ3: Fix distribution of Super Metroid prizes - #5303

Merged
NewSoupVi merged 1 commit into
ArchipelagoMW:mainfrom
KScl:smz3-sm-prize-fix
Sep 5, 2025
Merged

NewSoupVi merged 1 commit into
ArchipelagoMW:mainfrom
KScl:smz3-sm-prize-fix

Conversation

@KScl

@KScl KScl commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

What is this fixing or adding?

A combination of two bugs that seem to have been introduced when converting the upstream code to Python:

  • Distribution weights were being doubly subtracted from the given random number; this resulted in Blue Crystals being picked for SM bosses far more often than they should, as well as making it impossible to pick Red Crystals and Pendants for SM bosses. (n - (12 + 15 + 15) where n is between 0 and 35 is always less than 0)
  • In the Distribution constructor, passing in another Distribution attempted to turn the newly instantiated Distribution into a copy of it... by overwriting self, which doesn't work. After leaving __init__, that copy (and the changes made to it afterwards by other parameters) would be tossed out, and the result would always be the default Distribution weights. This was masked by the above bug; fixing that one without fixing this one resulted in occasionally attempting to place three Red Crystals, two Green Pendants, etc.

How was this tested?

Test generations showing Red Crystals and rarely, Pendants being placed on SM locations, where they were not before

@github-actions github-actions Bot added the waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. label Aug 8, 2025
@KScl

KScl commented Aug 8, 2025

Copy link
Copy Markdown
Contributor Author

Relevant upstream code: WorldState.cs:75-90

@lordlou

@ScipioWright ScipioWright added is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world. labels Aug 8, 2025

@ScipioWright ScipioWright left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The math makes much more sense now (I'd prefer if it was just getting a random number then figuring out if it's within a range directly instead of subtracting each time but it's not worth changing it that much), and the other bug here was understandable.

@lordlou lordlou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh this was indeed all wrong. Thanks for helping, much appreciated!

@ScipioWright ScipioWright added waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer. and removed waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels Aug 11, 2025
@NewSoupVi
NewSoupVi merged commit 5b5e2c3 into ArchipelagoMW:main Sep 5, 2025
eternalcode0 pushed a commit to eternalcode0/Archipelago that referenced this pull request Dec 20, 2025
eternalcode0 pushed a commit to eternalcode0/Archipelago that referenced this pull request Dec 21, 2025
wcoldren pushed a commit to wcoldren/Archipelago that referenced this pull request Jun 18, 2026
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. waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants