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

Bug: CollectionState.sweep_for_events() semantics may have been accidentally changed in #361 #3680

Closed
Mysteryem opened this issue Jul 23, 2024 · 4 comments

Comments

@Mysteryem
Copy link
Contributor

What happened?

I was looking at the history of CollectionState.sweep_for_events() to try to understand it better and noticed that the semantics changed in #361 (cebd7fb) and the change does not look intentional to me.

The semantics for reachable_events were previously equivalent to:
A and ((not B) or C) and D

{location for location in locations
 if location.event
 and (not key_only or getattr(location.item, "locked_dungeon_item", False)
 and location.can_reach(self)}

But in #361 (cebd7fb), the semantics changed to be equivalent to:
((A and (not B)) or C) and D

{location for location in locations
 if ((location.event and not key_only)
     or getattr(location.item, "locked_dungeon_item", False))
 and location.can_reach(self)}

This change in semantics is still present in the sweep_for_events() implementation today (https://github.com/ArchipelagoMW/Archipelago/blob/9c2933f8033c8e8b9d9acdd341b043d7eca89d76/BaseClasses.py#L688C9-L689C91):

locations = {location for location in locations if location.advancement and location not in self.events and
             not key_only or getattr(location.item, "locked_dungeon_item", False)}

Going by the code prior to #361, this should likely instead be

locations = {location for location in locations if location.advancement and location not in self.events and
             (not key_only or getattr(location.item, "locked_dungeon_item", False))}

I'm not sure what the implications of this being an unintended change are. There appear to be only two places which use key_only=True, so these and any items for which locked_dungeon_item exists and returns True, are likely the only places affected by the change in semantics.

state.sweep_for_events(key_only=True)

and
sphere_state.sweep_for_events(key_only=True, locations=locations)

What were the expected results?

#361 seems to have been intended as a performance change, not one that should have changed semantics.

Software

Local generation

@Exempt-Medic
Copy link
Member

@Berserker66 I suppose

Mysteryem added a commit to Mysteryem/Archipelago-ahit that referenced this issue Jul 25, 2024
Mysteryem added a commit to Mysteryem/Archipelago-ahit that referenced this issue Jul 25, 2024
@Berserker66
Copy link
Member

related fix: #2239

Mysteryem added a commit to Mysteryem/Archipelago-ahit that referenced this issue Jul 27, 2024
I think it's clear now that the change to location filtering semantics
was a bug because it was allowing the `key_only=True` case to have
locations which did not contain an advancement item.
@Exempt-Medic
Copy link
Member

So is this fixed now?

@Mysteryem
Copy link
Contributor Author

#2239 was merged which removes the key_only parameter, so the code that may have had unintentional changes to its semantics has been removed, so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants