Updated friendly limits to be more strict, optimized recalculate logic.

This commit is contained in:
massimilianodelliubaldini
2024-08-30 17:02:21 -04:00
parent 30f5d84ab3
commit b63ed86955
4 changed files with 21 additions and 12 deletions

View File

@@ -51,8 +51,8 @@ class GlobalOrbsanityBundleSize(Choice):
option_500_orbs = 500 option_500_orbs = 500
option_1000_orbs = 1000 option_1000_orbs = 1000
option_2000_orbs = 2000 option_2000_orbs = 2000
multiplayer_minimum = 5 multiplayer_minimum = 10
multiplayer_maximum = 400 multiplayer_maximum = 200
default = 20 default = 20
@@ -66,7 +66,7 @@ class PerLevelOrbsanityBundleSize(Choice):
option_10_orbs = 10 option_10_orbs = 10
option_25_orbs = 25 option_25_orbs = 25
option_50_orbs = 50 option_50_orbs = 50
multiplayer_minimum = 5 multiplayer_minimum = 10
default = 25 default = 25

View File

@@ -1,4 +1,4 @@
from BaseClasses import Location from BaseClasses import Location, CollectionState
from .GameID import jak1_name from .GameID import jak1_name
from .locs import (OrbLocations as Orbs, from .locs import (OrbLocations as Orbs,
CellLocations as Cells, CellLocations as Cells,
@@ -10,6 +10,13 @@ from .locs import (OrbLocations as Orbs,
class JakAndDaxterLocation(Location): class JakAndDaxterLocation(Location):
game: str = jak1_name game: str = jak1_name
# In AP 0.5.0, the base Location.can_reach function had its two boolean conditions swapped for a faster
# short-circuit for better performance. However, Jak seeds actually generate faster using the older method,
# which has been re-implemented below.
def can_reach(self, state: CollectionState) -> bool:
assert self.parent_region, "Can't reach location without region"
return self.parent_region.can_reach(state) and self.access_rule(state)
# Different tables for location groups. # Different tables for location groups.
# Each Item ID == its corresponding Location ID. While we're here, do all the ID conversions needed. # Each Item ID == its corresponding Location ID. While we're here, do all the ID conversions needed.

View File

@@ -49,10 +49,11 @@ def count_reachable_orbs_global(state: CollectionState,
multiworld: MultiWorld) -> int: multiworld: MultiWorld) -> int:
accessible_orbs = 0 accessible_orbs = 0
for region in multiworld.get_regions(player): # Cast all regions upfront to access their unique attributes.
if region.can_reach(state): for region in typing.cast(typing.List[JakAndDaxterRegion], multiworld.get_regions(player)):
# Only cast the region when we need to. # Rely on short-circuiting to skip region.can_reach whenever possible.
accessible_orbs += typing.cast(JakAndDaxterRegion, region).orb_count if region.orb_count > 0 and region.can_reach(state):
accessible_orbs += region.orb_count
return accessible_orbs return accessible_orbs
@@ -62,9 +63,10 @@ def count_reachable_orbs_level(state: CollectionState,
level_name: str = "") -> int: level_name: str = "") -> int:
accessible_orbs = 0 accessible_orbs = 0
# Need to cast all regions upfront. # Cast all regions upfront to access their unique attributes.
for region in typing.cast(typing.List[JakAndDaxterRegion], multiworld.get_regions(player)): for region in typing.cast(typing.List[JakAndDaxterRegion], multiworld.get_regions(player)):
if region.level_name == level_name and region.can_reach(state): # Rely on short-circuiting to skip region.can_reach whenever possible.
if region.level_name == level_name and region.orb_count > 0 and region.can_reach(state):
accessible_orbs += region.orb_count accessible_orbs += region.orb_count
return accessible_orbs return accessible_orbs

View File

@@ -54,8 +54,8 @@ class JakAndDaxterSettings(settings.Group):
description = "ArchipelaGOAL Root Directory" description = "ArchipelaGOAL Root Directory"
class EnforceFriendlyOptions(settings.Bool): class EnforceFriendlyOptions(settings.Bool):
"""Enforce friendly player options to be used in a multiplayer seed. """Enforce friendly player options in both single and multiplayer seeds. Disabling this allows for
Disabling this allows for more disruptive and challenging options, but may impact seed generation.""" more disruptive and challenging options, but may impact seed generation. Use at your own risk!"""
description = "ArchipelaGOAL Enforce Friendly Options" description = "ArchipelaGOAL Enforce Friendly Options"
root_directory: RootDirectory = RootDirectory("%appdata%/OpenGOAL-Mods/archipelagoal") root_directory: RootDirectory = RootDirectory("%appdata%/OpenGOAL-Mods/archipelagoal")