Skip to content

Commit

Permalink
Merge branch 'ArchipelagoMW:main' into sm64-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwhite authored Dec 4, 2024
2 parents 96b3c7b + 769fbc5 commit 43659cc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion worlds/hk/Options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing
import re
from dataclasses import dataclass, make_dataclass
from dataclasses import make_dataclass

from .ExtractedData import logic_options, starts, pool_options
from .Rules import cost_terms
Expand Down
4 changes: 2 additions & 2 deletions worlds/hk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _add(item_name: str, location_name: str, randomized: bool):

for shop, locations in self.created_multi_locations.items():
for _ in range(len(locations), getattr(self.options, shop_to_option[shop]).value):
loc = self.create_location(shop)
self.create_location(shop)
unfilled_locations += 1

# Balance the pool
Expand All @@ -356,7 +356,7 @@ def _add(item_name: str, location_name: str, randomized: bool):
if shops:
for _ in range(additional_shop_items):
shop = self.random.choice(shops)
loc = self.create_location(shop)
self.create_location(shop)
unfilled_locations += 1
if len(self.created_multi_locations[shop]) >= 16:
shops.remove(shop)
Expand Down
17 changes: 16 additions & 1 deletion worlds/witness/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,22 @@ def convert_requirement_option(requirement: List[Union[CollectionRule, SimpleIte
item_rules_converted = [lambda state: state.has(item, player, count)]
else:
item_counts = {item_rule.item_name: item_rule.item_count for item_rule in item_rules}
item_rules_converted = [lambda state: state.has_all_counts(item_counts, player)]
# Sort the list by which item you are least likely to have (E.g. last stage of progressive item chains)
sorted_item_list = sorted(
item_counts.keys(),
key=lambda item_name: item_counts[item_name] if ("Progressive" in item_name) else 1.5,
reverse=True
# 1.5 because you are less likely to have a single stage item than one copy of a 2-stage chain
# I did some testing and every part of this genuinely gives a tiiiiny performance boost over not having it!
)

if all(item_count == 1 for item_count in item_counts.values()):
# If all counts are one, just use state.has_all
item_rules_converted = [lambda state: state.has_all(sorted_item_list, player)]
else:
# If any count is higher than 1, use state.has_all_counts
sorted_item_counts = {item_name: item_counts[item_name] for item_name in sorted_item_list}
item_rules_converted = [lambda state: state.has_all_counts(sorted_item_counts, player)]

return collection_rules + item_rules_converted

Expand Down

0 comments on commit 43659cc

Please sign in to comment.