-
Notifications
You must be signed in to change notification settings - Fork 872
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
Timespinner: move options checks out of rules #4708
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,12 @@ class TimespinnerLogic: | |
flag_unchained_keys: bool | ||
flag_eye_spy: bool | ||
flag_specific_keycards: bool | ||
flag_enter_sandman: bool | ||
flag_back_to_the_future: bool | ||
flag_prism_break: bool | ||
flag_lock_key_amadeus: bool | ||
flag_gate_keep: bool | ||
flag_royal_roadblock: bool | ||
pyramid_keys_unlock: Optional[str] | ||
present_keys_unlock: Optional[str] | ||
past_keys_unlock: Optional[str] | ||
|
@@ -23,7 +28,13 @@ def __init__(self, player: int, options: Optional[TimespinnerOptions], | |
self.flag_specific_keycards = bool(options and options.specific_keycards) | ||
self.flag_eye_spy = bool(options and options.eye_spy) | ||
self.flag_unchained_keys = bool(options and options.unchained_keys) | ||
self.flag_enter_sandman = bool(options and options.enter_sandman) | ||
self.flag_back_to_the_future = bool(options and options.back_to_the_future) | ||
self.flag_prism_break = bool(options and options.prism_break) | ||
self.flag_lock_key_amadeus = bool(options and options.lock_key_amadeus) | ||
self.flag_pyramid_start = bool(options and options.pyramid_start) | ||
self.flag_gate_keep = bool(options and options.gate_keep) | ||
self.flag_royal_roadblock = bool(options and options.gate_keep) | ||
|
||
if precalculated_weights: | ||
if self.flag_unchained_keys: | ||
|
@@ -113,3 +124,18 @@ def can_teleport_to(self, state: CollectionState, era: str, gate: str) -> bool: | |
return self.time_keys_unlock == gate and state.has("Mysterious Warp Beacon", self.player) | ||
else: | ||
raise Exception("Invallid Era: {}".format(era)) | ||
|
||
def has_pyramid_warp(self, state: CollectionState) -> bool: | ||
return self.can_teleport_to(state, "Time", "GateGyre") or self.can_teleport_to(state, "Time", "GateLeftPyramid") or (not self.flag_unchained_keys and self.flag_enter_sandman) | ||
|
||
def has_present_access_from_refugee_camp(self, state: CollectionState) -> bool: | ||
return (self.flag_pyramid_start or self.flag_inverted) and self.flag_back_to_the_future and state.has_all({'Timespinner Wheel', 'Timespinner Spindle'}, self.player) | ||
|
||
def lock_key_amadeus_enabled(self) -> bool: | ||
return self.flag_lock_key_amadeus | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really a fan of having this method just delegate to checking the flag, but basically everything involving this flag has logic unique to one or two locations or regions meaning this approach is likely to be the most comprehensible. |
||
|
||
def can_traverse_drawbridge(self, state: CollectionState) -> bool: | ||
return not self.flag_gate_keep or state.has('Drawbridge Key', self.player) or self.has_upwarddash(state) | ||
|
||
def can_open_royal_towers_door(self, state: CollectionState) -> bool: | ||
return not self.flag_royal_roadblock or self.has_pink(state) |
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
Oops, something went wrong.
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.
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.
Does this really has a significant impact?
logic.lock_key_amadeus_enabled()
will still be evaluated every time the rule is called during the fill.Moving the whole
if
would really be significant as it would only be evaluated once instead of everytime the rule is evaluated.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 think you're correct that as written this doesn't actually have any significant impact, so I decided to do a set of test generations (10x with 64 players) without and with this change and didn't see a significant difference in generation time (28.1s average without, 27.9s average with).
Since I'm set up to check, I'm going to see if factoring the flags out of the rules entirely (as illustrated above) makes any significant difference.
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.
The latest commit here now shows a first pass at pulling all of the options checks out of LogicExtensions as well, instead favoring determining which function to use in advance at the time of setting the rules.
The result of the 10x test run as I described above is 27.6 seconds average generation time, which is a negligible improvement.
I no longer particularly think this is worth pursuing - the performance benefits don't seem to be there - but I'm going to leave this PR up for now for posterity.