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

Core: replace Location.event with advancement property #2871

Merged
merged 9 commits into from
Apr 14, 2024

Conversation

alwaysintreble
Copy link
Collaborator

What is this fixing or adding?

title. removes a ton of unnecessary event assignments in world implementations too.

How was this tested?

ran --multi 100 --seed 1 --skip_prog_balancing --spoiler 0 --skip_output with effected games and messenger. interestingly i would expect this to run slower but in my tests it seemed to run a bit faster? more testing to confirm this would be good.

If this makes graphical changes, please attach screenshots.

@github-actions github-actions bot added waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. affects: core Issues/PRs that touch core and may need additional validation. labels Feb 27, 2024
@alwaysintreble alwaysintreble added the waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world. label Feb 27, 2024
@alwaysintreble
Copy link
Collaborator Author

@Alchav @lordlou @Rosalie-A

Comment on lines 595 to +596
if location.progress_type != LocationProgressType.EXCLUDED \
and (location.player in players["locations"] or location.event
or (location.item and location.item.advancement)):
and (location.player in players["locations"] or location.advancement):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is how I would format this:

            if location.progress_type != LocationProgressType.EXCLUDED and (
                location.player in players["locations"] or location.advancement
            ):

Not saying this is better, just presenting another option in case you were looking for one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I'd rather leave it how it is due to it being the current style in AP and I don't think we ever decided on which one we should use going forward.

Copy link
Collaborator

@t3hf1gm3nt t3hf1gm3nt left a comment

Choose a reason for hiding this comment

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

Ran a few tests gens with a TLOZ yaml and checked the spoiler to make sure the events we have for the playthrough still showed up. all clear there so good in my book.

as for the claim that this change would make things faster, that i found inconclusive. tested with the same yaml with seeds 1, 10, and 100 as well as a few completely random seeds between current main and this PR, and sometimes main was quicker and other times the PR was quicker. only by 1 or 2 tenths of a second, think the only outlier was 5 tenths at most. EDIT: im a dumb dumb and realize that not running at the very least --skip_output might be throwing the times off, so throw my speed testing into the bin. i might look into running proper tests for that claim at a later time but tbh not worried about that personally

Copy link
Collaborator

@Jarno458 Jarno458 left a comment

Choose a reason for hiding this comment

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

the change to Timespinner LGTM, i didnt actually test it, but based on the logic the event bool got removed so it makes sense to remove it like you did

Copy link
Collaborator

@axe-y axe-y left a comment

Choose a reason for hiding this comment

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

I see 3 names change in DLC Quest, if it work it should be good.

Copy link
Collaborator

@Ziktofel Ziktofel left a comment

Choose a reason for hiding this comment

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

For SC2 it's only removing dead code. See Ziktofel#171

worlds/stardew_valley/__init__.py Outdated Show resolved Hide resolved
worlds/oot/__init__.py Outdated Show resolved Hide resolved
@alwaysintreble
Copy link
Collaborator Author

@jonloveslegos

@Jouramie
Copy link
Contributor

Jouramie commented Mar 1, 2024

I ran Stardew's performance tests with the 5.x.x branch. I take a little more time than before, but the difference is inside the std, so I would call that insignificant.

However, I ran --skip_output --seed 1 --multi 50 on DLC Quest with Coinsanity, and it seems around 5% slower. Not sure if it's just my low sample of 3 runs or why it would be slower...

@black-sliver
Copy link
Member

Checking Location.advancement should be slower than checking the old Location.event, but skips potential writes to Location.event (and fits more in cache), so the impact will depend on "simplicity" of fill.

I tested a couple of things (including 500 DLCQuest+coinsanity without prog balancing) and I get a slowdown of 1-2% across the board, which may or may not be noise. I've never seen a difference as high as 5%.

@Jouramie
Copy link
Contributor

Jouramie commented Mar 1, 2024

I was testing with prog balancing, I would assume that's why I saw a bigger difference.

@black-sliver
Copy link
Member

Prog balancing also had only 2% difference for me

@alwaysintreble
Copy link
Collaborator Author

machine specs could very easily influence it, but somewhere around a 1-5% drop sounds about right to me. i do think the rename is worth it but i'm unsure if swapping this to a property is worth it. i looked a bit into making CollectionState.events a more effective cache that would invalidate the performance loss here (and possibly give us a bit of gain), but that would be more of a rework that's very out of scope for this. if we don't think the property is worth the performance loss, i'm happy to change it back to an attribute since with the cleanup i've already done here it would only be a few lines of code.

@Alchav
Copy link
Contributor

Alchav commented Mar 3, 2024

idc

Copy link
Collaborator

@FlySniper FlySniper left a comment

Choose a reason for hiding this comment

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

Wargroove changes look good to me.

# Conflicts:
#	worlds/alttp/ItemPool.py
Copy link
Collaborator

@espeon65536 espeon65536 left a comment

Choose a reason for hiding this comment

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

oot generates and I didn't find anything that would break with grep, hopefully some obscure setting combo didn't slip by my notice

Copy link
Contributor

@jonloveslegos jonloveslegos left a comment

Choose a reason for hiding this comment

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

Barely anything was changed with Undertale, and what did change looks fine to me.

@nbrochu
Copy link
Collaborator

nbrochu commented Mar 15, 2024

Hmm if this is to be merged for 0.4.5, I think Zork will need a tweak too.

                location.event = isinstance(location_enum_item, ZorkGrandInquisitorEvents)

                if location.event:
                    location.place_locked_item(
                        ZorkGrandInquisitorItem(
                            data.event_item_name,
                            ItemClassification.progression,
                            None,
                            self.player,
                        )
                    )

Would need to become (?)

                if isinstance(location_enum_item, ZorkGrandInquisitorEvents):
                    location.place_locked_item(
                        ZorkGrandInquisitorItem(
                            data.event_item_name,
                            ItemClassification.progression,
                            None,
                            self.player,
                        )
                    )

I guess I should have never been manually setting .event anyway

@nbrochu
Copy link
Collaborator

nbrochu commented Mar 15, 2024

Might be worth checking the other new games too, just in case

# Conflicts:
#	worlds/sc2wol/Regions.py
#	worlds/stardew_valley/test/TestGeneration.py
#	worlds/stardew_valley/test/TestOptions.py
#	worlds/stardew_valley/test/TestRules.py
#	worlds/stardew_valley/test/checks/world_checks.py
#	worlds/stardew_valley/test/long/TestModsLong.py
#	worlds/stardew_valley/test/mods/TestMods.py
Copy link
Contributor

@Jouramie Jouramie left a comment

Choose a reason for hiding this comment

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

I looked again and found this. Otherwise, LGTM for Stardew.

worlds/stardew_valley/test/assertion/mod_assert.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@nbrochu nbrochu left a comment

Choose a reason for hiding this comment

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

Zork LGTM

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.

Didnt test SMZ3 but looks good to me.

@alwaysintreble alwaysintreble 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 Mar 26, 2024
@Exempt-Medic Exempt-Medic added the is: refactor/cleanup Improvements to code/output readability or organizization. label Apr 8, 2024
@Berserker66 Berserker66 merged commit 842a15f into ArchipelagoMW:main Apr 14, 2024
15 checks passed
EmilyV99 pushed a commit to EmilyV99/Archipelago that referenced this pull request Apr 15, 2024
EmilyV99 pushed a commit to EmilyV99/Archipelago that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: core Issues/PRs that touch core and may need additional validation. 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. waiting-on: world-maintainer Issue/PR is waiting for feedback or approval by the maintainer of a world.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet