Merged light/dark world marking

This commit is contained in:
codemann8
2022-10-31 13:43:18 -05:00
parent e83d0fa8e4
commit 8919729262
3 changed files with 35 additions and 60 deletions

View File

@@ -14,7 +14,7 @@ from Items import ItemFactory
from KeyDoorShuffle import validate_key_placement from KeyDoorShuffle import validate_key_placement
from OverworldGlitchRules import create_owg_connections from OverworldGlitchRules import create_owg_connections
from PotShuffle import shuffle_pots, shuffle_pot_switches from PotShuffle import shuffle_pots, shuffle_pot_switches
from Regions import create_regions, create_shops, mark_light_world_regions, mark_dark_world_regions, create_dungeon_regions, adjust_locations from Regions import create_regions, create_shops, mark_light_dark_world_regions, create_dungeon_regions, adjust_locations
from OWEdges import create_owedges from OWEdges import create_owedges
from OverworldShuffle import link_overworld, update_world_regions, create_flute_exits from OverworldShuffle import link_overworld, update_world_regions, create_flute_exits
from EntranceShuffle import link_entrances from EntranceShuffle import link_entrances
@@ -204,10 +204,7 @@ def main(args, seed=None, fish=None):
for player in range(1, world.players + 1): for player in range(1, world.players + 1):
link_doors(world, player) link_doors(world, player)
if world.mode[player] != 'inverted': mark_light_dark_world_regions(world, player)
mark_light_world_regions(world, player)
else:
mark_dark_world_regions(world, player)
logger.info(world.fish.translate("cli", "cli", "generating.itempool")) logger.info(world.fish.translate("cli", "cli", "generating.itempool"))
for player in range(1, world.players + 1): for player in range(1, world.players + 1):

View File

@@ -2,7 +2,7 @@ import RaceRandom as random, logging, copy
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from DungeonGenerator import GenerationException from DungeonGenerator import GenerationException
from BaseClasses import OWEdge, WorldType, RegionType, Direction, Terrain, PolSlot, Entrance from BaseClasses import OWEdge, WorldType, RegionType, Direction, Terrain, PolSlot, Entrance
from Regions import mark_dark_world_regions, mark_light_world_regions from Regions import mark_light_dark_world_regions
from OWEdges import OWTileRegions, OWEdgeGroups, OWEdgeGroupsTerrain, OWExitTypes, OpenStd, parallel_links, IsParallel from OWEdges import OWTileRegions, OWEdgeGroups, OWEdgeGroupsTerrain, OWExitTypes, OpenStd, parallel_links, IsParallel
from OverworldGlitchRules import create_owg_connections from OverworldGlitchRules import create_owg_connections
from Utils import bidict from Utils import bidict
@@ -843,8 +843,7 @@ def categorize_world_regions(world, player):
for exitname in OWExitTypes[type]: for exitname in OWExitTypes[type]:
world.get_entrance(exitname, player).spot_type = type world.get_entrance(exitname, player).spot_type = type
mark_light_world_regions(world, player) mark_light_dark_world_regions(world, player)
mark_dark_world_regions(world, player)
def update_world_regions(world, player): def update_world_regions(world, player):
if world.owMixed[player]: if world.owMixed[player]:

View File

@@ -1076,67 +1076,46 @@ def _create_region(player, name, type, hint='Hyrule', locations=None, exits=None
ret.locations.append(Location(player, location, address, crystal, hint_text, ret, None, player_address)) ret.locations.append(Location(player, location, address, crystal, hint_text, ret, None, player_address))
return ret return ret
def mark_light_world_regions(world, player): def mark_light_dark_world_regions(world, player):
# cross world caves may have some sections marked as both in_light_world, and in_dark_work. # cross world caves may have some sections marked as both in_light_world, and in_dark_work.
# That is ok. the bunny logic will check for this case and incorporate special rules. # That is ok. the bunny logic will check for this case and incorporate special rules.
queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld) # Note: I don't see why the order would matter, but the original Inverted code reversed the order
seen = set(queue) if world.mode[player] != 'inverted':
while queue: mark_light()
current = queue.popleft() mark_dark()
current.is_light_world = True else:
for exit in current.exits: mark_dark()
if exit.connected_region is None or exit.connected_region.type == RegionType.DarkWorld: # todo: remove none check mark_light()
# Don't venture into the dark world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)
queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld) def mark_light():
seen = set(queue) queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld)
while queue: seen = set(queue)
current = queue.popleft() while queue:
current.is_dark_world = True current = queue.popleft()
for exit in current.exits: current.is_light_world = True
if exit.connected_region is not None: for exit in current.exits:
if exit.connected_region.type == RegionType.LightWorld: if exit.connected_region is None or exit.connected_region.type == RegionType.DarkWorld: # todo: remove none check
# Don't venture into the light world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)
def mark_dark_world_regions(world, player):
# cross world caves may have some sections marked as both in_light_world, and in_dark_work.
# That is ok. the bunny logic will check for this case and incorporate special rules.
queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld)
seen = set(queue)
while queue:
current = queue.popleft()
current.is_dark_world = True
for exit in current.exits:
if exit.connected_region is None or exit.connected_region.type == RegionType.LightWorld: # todo: remove none check
# Don't venture into the light world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)
queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld)
seen = set(queue)
while queue:
current = queue.popleft()
current.is_light_world = True
for exit in current.exits:
if exit.connected_region is not None:
if exit.connected_region.type == RegionType.DarkWorld:
# Don't venture into the dark world # Don't venture into the dark world
continue continue
if exit.connected_region not in seen: if exit.connected_region not in seen:
seen.add(exit.connected_region) seen.add(exit.connected_region)
queue.append(exit.connected_region) queue.append(exit.connected_region)
def mark_dark():
queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld)
seen = set(queue)
while queue:
current = queue.popleft()
current.is_dark_world = True
for exit in current.exits:
if exit.connected_region is not None:
if exit.connected_region.type == RegionType.LightWorld:
# Don't venture into the light world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)
def create_shops(world, player): def create_shops(world, player):
world.shops[player] = [] world.shops[player] = []