mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-22 07:35:37 -07:00
* Sweep events per-player to reduce sweep iterations By finding all accessible locations per player and then collecting the items from those locations, if any collected items belong to a different player, then that player may be able to access more locations the next time all of their accessible locations are found. This reduces the number of iterations necessary to sweep through and collect from all accessible locations. * Also sweep per-player in MultiWorld.can_beat_game * Deduplicate code by using sweep_for_events in can_beat_game sweep_for_events has been modified to be able to return a generator and to be able to change the set of locations that are filtered out. This way, the same code can be used by both functions. * Skip checking locations by assuming each world only logically depends on itself While this assumption almost always holds true, worlds are allowed to logically depend on other worlds, so the sweep always double checks at the end by checking the locations of every world before finishing. * Fix missed update to CollectionState.collect implementation Collecting items with prevent_sweep=True (previously event=True) no longer always returns True, so the return value should now be checked. * Comment and variable name consistency/clarity accessible/inaccessible -> reachable/unreachable final sweep iteration -> extra sweep iteration maybe_final_sweep -> checking_if_finished * Apply suggestions from code review Use Iterator in return type hint instead of Iterable to help indicate that the returned value can only be iterated once. Be consistent in return statements. Because sweep_for_events can return a value now, the conditional branch that has no intended return value should explicitly return None. Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * Update terminology from 'event' to 'advancement' * Add typing overloads for sweep_for_advancements This makes it so type-checkers and IDEs can see which calls return `None` and which calls return `Iterator` so that it doesn't complain about returning an `Iterator` from `sweep_for_events` or about iterating through `None` in `can_beat_game`. Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> * Update comment for why discard the player after finding their locations A lack of clarity was brought up in review. * Update for removed typing import --------- Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
90 KiB
90 KiB