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

FFMQ: Efficiency Improvement and Use New Options Methods #2767

Merged
merged 10 commits into from
Jul 24, 2024

Conversation

Alchav
Copy link
Contributor

@Alchav Alchav commented Jan 26, 2024

What is this fixing or adding?

  • Converts rooms.yaml and entrances.yaml to python data so no yaml loading and converting takes place during runtime while the apworld is initialized. This saves a good few seconds of loading time.
  • Updates FFMQ to use new options methods
  • Removes some print statements that were left in by mistake.
  • Fixes a bug where one option was being checked twice and two others not checked at all, for determining if a map shuffle API call was necessary.
  • Entrance hints will now show locations at Mac's Ship (why did I go out of my way to exclude it? It is a mystery)

How was this tested?

Generating several times with various options.

@ScootyPuffJr1 ScootyPuffJr1 added the is: refactor/cleanup Improvements to code/output readability or organizization. label Jan 27, 2024
@ScipioWright ScipioWright added the waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. label Feb 10, 2024
# Conflicts:
#	worlds/ffmq/Client.py
#	worlds/ffmq/Regions.py
Copy link
Collaborator

@Zunawe Zunawe left a comment

Choose a reason for hiding this comment

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

  • Output.py line 102 uses self.multiworld.sky_coin_mode[self.player]
  • stage_generate_early could (should?) access options through the world variable
  • Regions.py line 70 uses self.multiworld.brown_boxes[self.player]
  • Regions.py line 213 uses multiworld.enemies_density[player]

Otherwise, does what it says on the tin.

World load on my machine goes from

  • ~0.75s to ~0.075s on Python 3.8
  • ~0.55s to ~0.08s on Python 3.11

worlds/ffmq/Client.py Show resolved Hide resolved
@Alchav
Copy link
Contributor Author

Alchav commented Mar 15, 2024

  • Output.py line 102 uses self.multiworld.sky_coin_mode[self.player]

    • stage_generate_early could (should?) access options through the world variable

    • Regions.py line 70 uses self.multiworld.brown_boxes[self.player]

    • Regions.py line 213 uses multiworld.enemies_density[player]

Otherwise, does what it says on the tin.

World load on my machine goes from

* ~0.75s to ~0.075s on Python 3.8

* ~0.55s to ~0.08s on Python 3.11

Fixed

Copy link
Collaborator

@Zunawe Zunawe left a comment

Choose a reason for hiding this comment

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

Looks like all options access was converted.

hint.append((subregion.split("Subregion ")[-1] + (" Region" if subregion not
in single_location_regions else "")))
if self.multiworld.map_shuffle[self.player] != "overworld" and subregion not in \
("Subregion Mac's Ship", "Subregion Doom Castle"):
if self.options.map_shuffle != "overworld":
Copy link
Member

@Exempt-Medic Exempt-Medic Apr 19, 2024

Choose a reason for hiding this comment

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

Just checking that the removal of the subregion check here is intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checking that the removal of the subregion check here is intended.

From the description of this PR:

Entrance hints will now show locations at Mac's Ship (why did I go out of my way to exclude it? It is a mystery)

Copy link
Member

Choose a reason for hiding this comment

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

And I wasn't sure if Doom Castle was relevant to that. But by your answer, I'll just assume it was

Copy link
Member

@Exempt-Medic Exempt-Medic left a comment

Choose a reason for hiding this comment

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

I had one comment on a removed bit of code. Otherwise the changes all LGTM. Merged into main and generated ten multiworlds with 100 random yamls. Everything generated fine and did not hit any deprecated options warning. Searched through the code as well and did not find any instances of that or per_slot_randoms.

@Exempt-Medic Exempt-Medic 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: peer-review Issue/PR has not been reviewed by enough people yet. labels Apr 19, 2024
Copy link
Member

@NewSoupVi NewSoupVi left a comment

Choose a reason for hiding this comment

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

Ready to merge, just noticed one small thing

Comment on lines 75 to 76
if self.options.enemies_scaling_lower.value > \
self.options.enemies_scaling_upper.value:
Copy link
Member

Choose a reason for hiding this comment

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

This is short enough to be on one line now, no? :)

Same with a lot of the following lines

Copy link
Member

Choose a reason for hiding this comment

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

+1
It's really hard to read. also the (..., ...) = (..., ...) assignment below is even worse with the breaks. If it needs breaks, there is no reason to do tuple assignments like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Member

@black-sliver black-sliver left a comment

Choose a reason for hiding this comment

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

Can you change settings_template in Output.py to use Utils.parse_yaml? (see below)


rooms = yaml.load(pkgutil.get_data(__name__, "data/rooms.yaml"), yaml.Loader)
Copy link
Member

@black-sliver black-sliver May 14, 2024

Choose a reason for hiding this comment

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

I think we should be more thorough in reviews (and hopefully some peer reviewers see this): for yaml this should've been Utils.parse_yaml, which is both safer and (since another PR was joined) 7x faster than this old code. There are very few reasons to use anything else for yaml. (Changing to non-yaml, as you did, is even better though)

Comment on lines 75 to 76
if self.options.enemies_scaling_lower.value > \
self.options.enemies_scaling_upper.value:
Copy link
Member

Choose a reason for hiding this comment

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

+1
It's really hard to read. also the (..., ...) = (..., ...) assignment below is even worse with the breaks. If it needs breaks, there is no reason to do tuple assignments like this.

@Exempt-Medic Exempt-Medic added the waiting-on: author Issue/PR is waiting for feedback or changes from its author. label May 21, 2024
@ThePhar ThePhar removed the waiting-on: core-review Issue/PR has been peer-reviewed and is ready to be merged or needs input from a core maintainer. label Jun 1, 2024
@Alchav
Copy link
Contributor Author

Alchav commented Jun 23, 2024

Can you change settings_template in Output.py to use Utils.parse_yaml? (see below)

Done

@Alchav Alchav requested a review from NewSoupVi June 27, 2024 04:23
@Exempt-Medic Exempt-Medic 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: author Issue/PR is waiting for feedback or changes from its author. labels Jul 19, 2024
@NewSoupVi NewSoupVi merged commit e7dbfa7 into ArchipelagoMW:main Jul 24, 2024
17 checks passed
@TreZc0
Copy link

TreZc0 commented Jul 24, 2024

This should be reverted, as it currently breaks SNI connection on FFMQ.
The reason is the one line change in client.py

@Exempt-Medic
Copy link
Member

@Alchav can just make another PR, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: refactor/cleanup Improvements to code/output readability or organizization. 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.

9 participants