-
Notifications
You must be signed in to change notification settings - Fork 558
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
The Witness: Rules Optimisation #3617
Draft
NewSoupVi
wants to merge
104
commits into
ArchipelagoMW:main
Choose a base branch
from
NewSoupVi:rules_optimization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…normal postgame is enabled
Co-authored-by: Exempt-Medic <[email protected]>
… into panel_hunt_r
ae0888b
to
a351427
Compare
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: peer-review
Issue/PR has not been reviewed by enough people yet.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The rules in The Witness are automatically generated in a "RandoCore" kind of way.
This means that each requirement is a Set[Set[str]], and is then converted first to a List[List[CollectionRule]], and then to a CollectionRule via
any(all(...) ...)
This introduces a lot of function call overhead.
In this PR, I aimed to catch some of these cases.
lambda state: any(all([[]]))
, instead it just skips setting an access rule.len(rule) == 1
), we skip the outerany
and just callall
on the one option that exists.len(rule) == 1
) and that one option only has a single element (len(rule[0]) == 1
), we skip both theany
and theall
and set the singular CollectionRule as the access rule directly.state.has_all_counts
, instead of chaining togetherstate.has
in an inefficient way.Tested
Using the unit tests added in a different PR, and by comparing outputs with the same seed
Benchmark
This leads to tangible improvements - A two player MultiWorld with
shuffle_doors: panels
generates in 0.78s instead of 0.95s.Drafted for now because I'm still debating how I want to structure this code. Also, it's based on the panel hunt PR because of a change that PR makes to how lasers are counted.