-
Notifications
You must be signed in to change notification settings - Fork 775
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: Better scaling explicit indirect conditions #4582
base: main
Are you sure you want to change the base?
Core: Better scaling explicit indirect conditions #4582
Conversation
When the number of connections to retry was large and `queue` was large `new_entrance not in queue` would get slow. For the average supported world, the difference this change makes is negligible. For a game like Blasphemous, with a lot of explicit indirect conditions, generation of 10 template Blasphemous yamls with `--skip_output --seed 1` and progression balancing disabled went from 19.0s to 17.9s (5.9% reduction in generation duration).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wonder if it'd be faster to rewrite this whole thing to wait until the queue is empty while building a list of new regions, then add all new indirect conditions to the queue at once somehow
Something like
while queue: # Outer loop which makes sure to retry indirect conditions
new_regions_in_iteration = []
while queue: # Inner loop which has the normal code
... normal code, but ...
if entrance.can_reach(state):
new_regions_in_iteration.append(entrance.target)
for region in new_regions_in_iteration:
for region, entrances in multiworld.indirect_conditions[player].get(region, []):
if entrance not in blocked_connections ór entrance.target.can_reach():
continue
queue.push(entrance)
Idk that's probably very wrong
Actually if what I suggested works we could probably even merge the two different functions again? 🤔 Anyway |
BaseClasses.py
Outdated
queue.append(new_entrance) | ||
entrances = self.multiworld.indirect_connections.get(new_region) | ||
if entrances is not None: | ||
entrances = entrances.intersection(blocked_connections) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entrances = entrances.intersection(blocked_connections) | |
entrances.intersection_update(blocked_connections) |
nitpicky, admittedly, but if we're using _update one line below, I feel this looks better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new set needs to be created here because entrances
starts off as a set instance that is stored within self.multiworld.indirect_connections
, which must not be modified by this function.
I could make a new variable for better clarity.
relevant_entrances = entrances.intersection(blocked_connections)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to copy it once at the start then, so that you can modify the instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I don't see how copying the set would help.
first_set.intersection(second_set)
only needs to create a new empty set, iterate the smaller of the two sets, and add the iterated elements that are in the larger set into the new empty set.
Copying the set should take more time and memory.
What is this fixing or adding?
When the number of connections to retry was large and
queue
was largenew_entrance not in queue
would get slow.For the average supported world, the difference this change makes is negligible.
For a game like Blasphemous, with a lot of explicit indirect conditions, generation of 10 template Blasphemous yamls with
--skip_output --seed 1
and progression balancing disabled went from 19.0s to 17.9s (5.9% reduction in generation duration).How was this tested?
Ran generations before and after, producing identical results