Initial approach to eliminating inaccessible regions resulting from OW Layout Shuffle

This commit is contained in:
codemann8
2021-11-30 11:37:20 -06:00
parent b4173044d7
commit 4e4b08da4f

View File

@@ -280,6 +280,12 @@ def link_overworld(world, player):
trimmed_groups = remove_reserved(world, trimmed_groups, connected_edges, player) trimmed_groups = remove_reserved(world, trimmed_groups, connected_edges, player)
groups = reorganize_groups(world, trimmed_groups, player) groups = reorganize_groups(world, trimmed_groups, player)
tries = 10
valid_layout = False
connected_edge_cache = connected_edges.copy()
while not valid_layout and tries > 0:
connected_edges = connected_edge_cache.copy()
if world.mode[player] == 'standard': if world.mode[player] == 'standard':
random.shuffle(groups[2:]) # keep first 2 groups (Standard) first random.shuffle(groups[2:]) # keep first 2 groups (Standard) first
else: else:
@@ -321,7 +327,11 @@ def link_overworld(world, player):
logging.getLogger('').warning("Edge '%s' could not find a valid connection" % back_set[0]) logging.getLogger('').warning("Edge '%s' could not find a valid connection" % back_set[0])
assert len(connected_edges) == len(default_connections) * 2, connected_edges assert len(connected_edges) == len(default_connections) * 2, connected_edges
# TODO: Reshuffle some areas if impossible to reach, exception if non-dungeon ER enabled or if area is LW with no portal and flute shuffle is enabled world.owsectors[player] = build_sectors(world, player)
valid_layout = validate_layout(world, player)
tries -= 1
assert valid_layout, 'Could not find a valid OW layout'
# flute shuffle # flute shuffle
def connect_flutes(flute_destinations): def connect_flutes(flute_destinations):
@@ -914,6 +924,20 @@ def build_accessible_region_list(world, start_region, player, build_copy_world=F
return explored_regions return explored_regions
def validate_layout(world, player):
sectors = [[r for l in s for r in l] for s in world.owsectors[player]]
for sector in sectors:
entrances_present = False
for region_name in sector:
region = world.get_region(region_name, player)
if any(x.spot_type == 'Entrance' for x in region.exits):
entrances_present = True
break
if not entrances_present and not all(r in isolated_regions for r in sector):
return False
return True
test_connections = [ test_connections = [
#('Links House ES', 'Octoballoon WS'), #('Links House ES', 'Octoballoon WS'),
#('Links House NE', 'Lost Woods Pass SW') #('Links House NE', 'Lost Woods Pass SW')
@@ -1670,6 +1694,11 @@ default_connections = [#('Lost Woods NW', 'Master Sword Meadow SC'),
('East Dark Death Mountain EN', 'Turtle Rock WN') ('East Dark Death Mountain EN', 'Turtle Rock WN')
] ]
isolated_regions = [
'Death Mountain Floating Island',
'Mimic Cave Ledge'
]
flute_data = { flute_data = {
#Slot LW Region DW Region OWID VRAM BG Y BG X Link Y Link X Cam Y Cam X Unk1 Unk2 IconY IconX AltY AltX #Slot LW Region DW Region OWID VRAM BG Y BG X Link Y Link X Cam Y Cam X Unk1 Unk2 IconY IconX AltY AltX
0x09: (['Lost Woods East Area', 'Skull Woods Forest'], 0x00, 0x1042, 0x022e, 0x0202, 0x0290, 0x0288, 0x029b, 0x028f, 0xfff2, 0x000e, 0x0290, 0x0288, 0x0290, 0x0290), 0x09: (['Lost Woods East Area', 'Skull Woods Forest'], 0x00, 0x1042, 0x022e, 0x0202, 0x0290, 0x0288, 0x029b, 0x028f, 0xfff2, 0x000e, 0x0290, 0x0288, 0x0290, 0x0290),