From bdde8591a761112cbf04dc1324d725d18618829e Mon Sep 17 00:00:00 2001 From: codemann8 Date: Fri, 16 Jul 2021 19:47:47 -0500 Subject: [PATCH 1/4] Converted Tile Regions to bidict object --- OWEdges.py | 635 +++++++++++++++++++------------------------- OverworldShuffle.py | 8 +- 2 files changed, 280 insertions(+), 363 deletions(-) diff --git a/OWEdges.py b/OWEdges.py index 3d3a4bd9..b8c5ceab 100644 --- a/OWEdges.py +++ b/OWEdges.py @@ -687,365 +687,282 @@ OWEdgeGroups = { ) } -OWTileRegions = { - 0x00: [ - 'Lost Woods West Area', - 'Lost Woods East Area' - ], - 0x02: [ - 'Lumberjack Area' - ], - 0x03: [ - 'West Death Mountain (Top)', - 'Spectacle Rock Ledge', - 'West Death Mountain (Bottom)' - ], - 0x05: [ - 'Death Mountain Floating Island', - 'East Death Mountain (Top West)', - 'East Death Mountain (Top East)', - 'Spiral Cave Ledge', - 'Mimic Cave Ledge', - 'Fairy Ascension Ledge', - 'Fairy Ascension Plateau', - 'East Death Mountain (Bottom Left)', - 'East Death Mountain (Bottom)' - ], - 0x07: [ - 'Death Mountain TR Pegs', - 'Death Mountain TR Pegs Ledge' - ], - 0x0a: [ - 'Mountain Entry Area', - 'Mountain Entry Entrance', - 'Mountain Entry Ledge' - ], - 0x0f: [ - 'Zora Waterfall Area', - 'Zora Waterfall Water', - 'Waterfall of Wishing Cave' - ], - 0x10: [ - 'Lost Woods Pass West Area', - 'Lost Woods Pass East Top Area', - 'Lost Woods Pass East Bottom Area' - ], - 0x11: [ - 'Kakariko Fortune Area' - ], - 0x12: [ - 'Kakariko Pond Area' - ], - 0x13: [ - 'Sanctuary Area', - 'Bonk Rock Ledge' - ], - 0x14: [ - 'Graveyard Area', - 'Graveyard Ledge', - 'Kings Grave Area' - ], - 0x15: [ - 'River Bend Area', - 'River Bend East Bank', - 'River Bend Water' - ], - 0x16: [ - 'Potion Shop Area', - 'Potion Shop Northeast', - 'Potion Shop Water' - ], - 0x17: [ - 'Zora Approach Area', - 'Zora Approach Ledge', - 'Zora Approach Water' - ], - 0x18: [ - 'Kakariko Area', - 'Kakariko Southwest', - 'Kakariko Grass Yard' - ], - 0x1a: [ - 'Forgotten Forest Area' - ], - 0x1b: [ - 'Hyrule Castle Area', - 'Hyrule Castle Southwest', - 'Hyrule Castle Courtyard', - 'Hyrule Castle Courtyard Northeast', - 'Hyrule Castle Ledge', - 'Hyrule Castle East Entry' - ], - 0x1d: [ - 'Wooden Bridge Area', - 'Wooden Bridge Northeast', - 'Wooden Bridge Water' - ], - 0x1e: [ - 'Eastern Palace Area' - ], - 0x22: [ - 'Blacksmith Area', - 'Bat Cave Ledge' - ], - 0x25: [ - 'Sand Dunes Area' - ], - 0x28: [ - 'Maze Race Area', - 'Maze Race Ledge', - 'Maze Race Prize' - ], - 0x29: [ - 'Kakariko Suburb Area' - ], - 0x2a: [ - 'Flute Boy Area', - 'Flute Boy Pass' - ], - 0x2b: [ - 'Central Bonk Rocks Area' - ], - 0x2c: [ - 'Links House Area' - ], - 0x2d: [ - 'Stone Bridge Area', - 'Stone Bridge Water' - ], - 0x2e: [ - 'Tree Line Area', - 'Tree Line Water' - ], - 0x2f: [ - 'Eastern Nook Area' - ], - 0x30: [ - 'Desert Area', - 'Desert Ledge', - 'Desert Palace Entrance (North) Spot', - 'Desert Checkerboard Ledge', - 'Desert Palace Stairs', - 'Desert Palace Mouth', - 'Desert Palace Teleporter Ledge', - 'Bombos Tablet Ledge' - ], - 0x32: [ - 'Flute Boy Approach Area', - 'Flute Boy Bush Entry', - 'Cave 45 Ledge' - ], - 0x33: [ - 'C Whirlpool Area', - 'C Whirlpool Water', - 'C Whirlpool Outer Area' - ], - 0x34: [ - 'Statues Area', - 'Statues Water' - ], - 0x35: [ - 'Lake Hylia Area', - 'Lake Hylia South Shore', - 'Lake Hylia Northeast Bank', - 'Lake Hylia Central Island', - 'Lake Hylia Island', - 'Lake Hylia Water' - ], - 0x37: [ - 'Ice Cave Area' - ], - 0x3a: [ - 'Desert Pass Area', - 'Desert Pass Southeast', - 'Desert Pass Ledge' - ], - 0x3b: [ - 'Dam Area' - ], - 0x3c: [ - 'South Pass Area' - ], - 0x3f: [ - 'Octoballoon Area', - 'Octoballoon Water', - 'Octoballoon Water Ledge' - ], - 0x40: [ - 'Skull Woods Forest', - 'Skull Woods Portal Entry', - 'Skull Woods Forest (West)', - 'Skull Woods Forgotten Path (Southwest)', - 'Skull Woods Forgotten Path (Northeast)' - ], - 0x42: [ - 'Dark Lumberjack Area' - ], - 0x43: [ - 'West Dark Death Mountain (Top)', - 'GT Approach', - 'West Dark Death Mountain (Bottom)' - ], - 0x45: [ - 'East Dark Death Mountain (Top)', - 'East Dark Death Mountain (Bottom Left)', - 'East Dark Death Mountain (Bottom)' - ], - 0x47: [ - 'Turtle Rock Area', - 'Turtle Rock Ledge' - ], - 0x4a: [ - 'Bumper Cave Area', - 'Bumper Cave Entrance', - 'Bumper Cave Ledge' - ], - 0x4f: [ - 'Catfish Area' - ], - 0x50: [ - 'Skull Woods Pass West Area', - 'Skull Woods Pass East Top Area', - 'Skull Woods Pass East Bottom Area' - ], - 0x51: [ - 'Dark Fortune Area' - ], - 0x52: [ - 'Outcast Pond Area' - ], - 0x53: [ - 'Dark Chapel Area' - ], - 0x54: [ - 'Dark Graveyard Area' - ], - 0x55: [ - 'Qirn Jump Area', - 'Qirn Jump East Bank', - 'Qirn Jump Water' - ], - 0x56: [ - 'Dark Witch Area', - 'Dark Witch Northeast', - 'Dark Witch Water' - ], - 0x57: [ - 'Catfish Approach Area', - 'Catfish Approach Ledge', - 'Catfish Approach Water' - ], - 0x58: [ - 'Village of Outcasts Area', - 'Dark Grassy Lawn' - ], - 0x5a: [ - 'Shield Shop Area', - 'Shield Shop Fence' - ], - 0x5b: [ - 'Pyramid Area', - 'Pyramid Exit Ledge', - 'Pyramid Pass' - ], - 0x5d: [ - 'Broken Bridge Area', - 'Broken Bridge Northeast', - 'Broken Bridge West', - 'Broken Bridge Water' - ], - 0x5e: [ - 'Palace of Darkness Area' - ], - 0x62: [ - 'Hammer Pegs Area', - 'Hammer Pegs Entry' - ], - 0x65: [ - 'Dark Dunes Area' - ], - 0x68: [ - 'Dig Game Area', - 'Dig Game Ledge' - ], - 0x69: [ - 'Frog Area', - 'Frog Prison', - 'Archery Game Area' - ], - 0x6a: [ - 'Stumpy Area', - 'Stumpy Pass' - ], - 0x6b: [ - 'Dark Bonk Rocks Area' - ], - 0x6c: [ - 'Big Bomb Shop Area' - ], - 0x6d: [ - 'Hammer Bridge North Area', - 'Hammer Bridge South Area', - 'Hammer Bridge Water' - ], - 0x6e: [ - 'Dark Tree Line Area', - 'Dark Tree Line Water' - ], - 0x6f: [ - 'Palace of Darkness Nook Area' - ], - 0x70: [ - 'Misery Mire Area', - 'Misery Mire Teleporter Ledge' - ], - 0x72: [ - 'Stumpy Approach Area', - 'Stumpy Approach Bush Entry' - ], - 0x73: [ - 'Dark C Whirlpool Area', - 'Dark C Whirlpool Water', - 'Dark C Whirlpool Outer Area' - ], - 0x74: [ - 'Hype Cave Area', - 'Hype Cave Water' - ], - 0x75: [ - 'Ice Lake Area', - 'Ice Lake Northeast Bank', - 'Ice Lake Ledge (West)', - 'Ice Lake Ledge (East)', - 'Ice Lake Water', - 'Ice Lake Moat', - 'Ice Palace Area' - ], - 0x77: [ - 'Shopping Mall Area' - ], - 0x7a: [ - 'Swamp Nook Area' - ], - 0x7b: [ - 'Swamp Area' - ], - 0x7c: [ - 'Dark South Pass Area' - ], - 0x7f: [ - 'Bomber Corner Area', - 'Bomber Corner Water', - 'Bomber Corner Water Ledge' - ], - 0x80: [ - 'Master Sword Meadow', - 'Hobo Bridge' - ], - 0x81: [ - 'Zoras Domain' - ] -} +OWTileRegions = bidict({ + 'Lost Woods West Area': 0x00, + 'Lost Woods East Area': 0x00, + + 'Lumberjack Area': 0x02, + + 'West Death Mountain (Top)': 0x03, + 'Spectacle Rock Ledge': 0x03, + 'West Death Mountain (Bottom)': 0x03, + + 'Death Mountain Floating Island': 0x05, + 'East Death Mountain (Top West)': 0x05, + 'East Death Mountain (Top East)': 0x05, + 'Spiral Cave Ledge': 0x05, + 'Mimic Cave Ledge': 0x05, + 'Fairy Ascension Ledge': 0x05, + 'Fairy Ascension Plateau': 0x05, + 'East Death Mountain (Bottom Left)': 0x05, + 'East Death Mountain (Bottom)': 0x05, + + 'Death Mountain TR Pegs': 0x07, + 'Death Mountain TR Pegs Ledge': 0x07, + + 'Mountain Entry Area': 0x0a, + 'Mountain Entry Entrance': 0x0a, + 'Mountain Entry Ledge': 0x0a, + + 'Zora Waterfall Area': 0x0f, + 'Zora Waterfall Water': 0x0f, + 'Waterfall of Wishing Cave': 0x0f, + + 'Lost Woods Pass West Area': 0x10, + 'Lost Woods Pass East Top Area': 0x10, + 'Lost Woods Pass East Bottom Area': 0x10, + + 'Kakariko Fortune Area': 0x11, + + 'Kakariko Pond Area': 0x12, + + 'Sanctuary Area': 0x13, + 'Bonk Rock Ledge': 0x13, + + 'Graveyard Area': 0x14, + 'Graveyard Ledge': 0x14, + 'Kings Grave Area': 0x14, + + 'River Bend Area': 0x15, + 'River Bend East Bank': 0x15, + 'River Bend Water': 0x15, + + 'Potion Shop Area': 0x16, + 'Potion Shop Northeast': 0x16, + 'Potion Shop Water': 0x16, + + 'Zora Approach Area': 0x17, + 'Zora Approach Ledge': 0x17, + 'Zora Approach Water': 0x17, + + 'Kakariko Area': 0x18, + 'Kakariko Southwest': 0x18, + 'Kakariko Grass Yard': 0x18, + + 'Forgotten Forest Area': 0x1a, + + 'Hyrule Castle Area': 0x1b, + 'Hyrule Castle Southwest': 0x1b, + 'Hyrule Castle Courtyard': 0x1b, + 'Hyrule Castle Courtyard Northeast': 0x1b, + 'Hyrule Castle Ledge': 0x1b, + 'Hyrule Castle East Entry': 0x1b, + + 'Wooden Bridge Area': 0x1d, + 'Wooden Bridge Northeast': 0x1d, + 'Wooden Bridge Water': 0x1d, + + 'Eastern Palace Area': 0x1e, + + 'Blacksmith Area': 0x22, + 'Bat Cave Ledge': 0x22, + + 'Sand Dunes Area': 0x25, + + 'Maze Race Area': 0x28, + 'Maze Race Ledge': 0x28, + 'Maze Race Prize': 0x28, + + 'Kakariko Suburb Area': 0x29, + + 'Flute Boy Area': 0x2a, + 'Flute Boy Pass': 0x2a, + + 'Central Bonk Rocks Area': 0x2b, + + 'Links House Area': 0x2c, + + 'Stone Bridge Area': 0x2d, + 'Stone Bridge Water': 0x2d, + + 'Tree Line Area': 0x2e, + 'Tree Line Water': 0x2e, + + 'Eastern Nook Area': 0x2f, + + 'Desert Area': 0x30, + 'Desert Ledge': 0x30, + 'Desert Palace Entrance (North) Spot': 0x30, + 'Desert Checkerboard Ledge': 0x30, + 'Desert Palace Stairs': 0x30, + 'Desert Palace Mouth': 0x30, + 'Desert Palace Teleporter Ledge': 0x30, + 'Bombos Tablet Ledge': 0x30, + + 'Flute Boy Approach Area': 0x32, + 'Flute Boy Bush Entry': 0x32, + 'Cave 45 Ledge': 0x32, + + 'C Whirlpool Area': 0x33, + 'C Whirlpool Water': 0x33, + 'C Whirlpool Outer Area': 0x33, + + 'Statues Area': 0x34, + 'Statues Water': 0x34, + + 'Lake Hylia Area': 0x35, + 'Lake Hylia South Shore': 0x35, + 'Lake Hylia Northeast Bank': 0x35, + 'Lake Hylia Central Island': 0x35, + 'Lake Hylia Island': 0x35, + 'Lake Hylia Water': 0x35, + + 'Ice Cave Area': 0x37, + + 'Desert Pass Area': 0x3a, + 'Desert Pass Southeast': 0x3a, + 'Desert Pass Ledge': 0x3a, + + 'Dam Area': 0x3b, + + 'South Pass Area': 0x3c, + + 'Octoballoon Area': 0x3f, + 'Octoballoon Water': 0x3f, + 'Octoballoon Water Ledge': 0x3f, + + 'Skull Woods Forest': 0x40, + 'Skull Woods Portal Entry': 0x40, + 'Skull Woods Forest (West)': 0x40, + 'Skull Woods Forgotten Path (Southwest)': 0x40, + 'Skull Woods Forgotten Path (Northeast)': 0x40, + + 'Dark Lumberjack Area': 0x42, + + 'West Dark Death Mountain (Top)': 0x43, + 'GT Approach': 0x43, + 'West Dark Death Mountain (Bottom)': 0x43, + + 'East Dark Death Mountain (Top)': 0x45, + 'East Dark Death Mountain (Bottom Left)': 0x45, + 'East Dark Death Mountain (Bottom)': 0x45, + + 'Turtle Rock Area': 0x47, + 'Turtle Rock Ledge': 0x47, + + 'Bumper Cave Area': 0x4a, + 'Bumper Cave Entrance': 0x4a, + 'Bumper Cave Ledge': 0x4a, + + 'Catfish Area': 0x4f, + + 'Skull Woods Pass West Area': 0x50, + 'Skull Woods Pass East Top Area': 0x50, + 'Skull Woods Pass East Bottom Area': 0x50, + + 'Dark Fortune Area': 0x51, + + 'Outcast Pond Area': 0x52, + + 'Dark Chapel Area': 0x53, + + 'Dark Graveyard Area': 0x54, + + 'Qirn Jump Area': 0x55, + 'Qirn Jump East Bank': 0x55, + 'Qirn Jump Water': 0x55, + + 'Dark Witch Area': 0x56, + 'Dark Witch Northeast': 0x56, + 'Dark Witch Water': 0x56, + + 'Catfish Approach Area': 0x57, + 'Catfish Approach Ledge': 0x57, + 'Catfish Approach Water': 0x57, + + 'Village of Outcasts Area': 0x58, + 'Dark Grassy Lawn': 0x58, + + 'Shield Shop Area': 0x5a, + 'Shield Shop Fence': 0x5a, + + 'Pyramid Area': 0x5b, + 'Pyramid Exit Ledge': 0x5b, + 'Pyramid Pass': 0x5b, + + 'Broken Bridge Area': 0x5d, + 'Broken Bridge Northeast': 0x5d, + 'Broken Bridge West': 0x5d, + 'Broken Bridge Water': 0x5d, + + 'Palace of Darkness Area': 0x5e, + + 'Hammer Pegs Area': 0x62, + 'Hammer Pegs Entry': 0x62, + + 'Dark Dunes Area': 0x65, + + 'Dig Game Area': 0x68, + 'Dig Game Ledge': 0x68, + + 'Frog Area': 0x69, + 'Frog Prison': 0x69, + 'Archery Game Area': 0x69, + + 'Stumpy Area': 0x6a, + 'Stumpy Pass': 0x6a, + + 'Dark Bonk Rocks Area': 0x6b, + + 'Big Bomb Shop Area': 0x6c, + + 'Hammer Bridge North Area': 0x6d, + 'Hammer Bridge South Area': 0x6d, + 'Hammer Bridge Water': 0x6d, + + 'Dark Tree Line Area': 0x6e, + 'Dark Tree Line Water': 0x6e, + + 'Palace of Darkness Nook Area': 0x6f, + + 'Misery Mire Area': 0x70, + 'Misery Mire Teleporter Ledge': 0x70, + + 'Stumpy Approach Area': 0x72, + 'Stumpy Approach Bush Entry': 0x72, + + 'Dark C Whirlpool Area': 0x73, + 'Dark C Whirlpool Water': 0x73, + 'Dark C Whirlpool Outer Area': 0x73, + + 'Hype Cave Area': 0x74, + 'Hype Cave Water': 0x74, + + 'Ice Lake Area': 0x75, + 'Ice Lake Northeast Bank': 0x75, + 'Ice Lake Ledge (West)': 0x75, + 'Ice Lake Ledge (East)': 0x75, + 'Ice Lake Water': 0x75, + 'Ice Lake Moat': 0x75, + 'Ice Palace Area': 0x75, + + 'Shopping Mall Area': 0x77, + + 'Swamp Nook Area': 0x7a, + + 'Swamp Area': 0x7b, + + 'Dark South Pass Area': 0x7c, + + 'Bomber Corner Area': 0x7f, + 'Bomber Corner Water': 0x7f, + 'Bomber Corner Water Ledge': 0x7f, + + 'Master Sword Meadow': 0x80, + 'Hobo Bridge': 0x80, + + 'Zoras Domain': 0x81 +}) OWTileGroups = { ("Woods", "Regular"): ( diff --git a/OverworldShuffle.py b/OverworldShuffle.py index 3a700045..e710b917 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -30,18 +30,18 @@ def link_overworld(world, player): exist_owids.extend(lw_owids) exist_owids.extend(dw_owids) for owid in lw_owids: - exist_lw_regions.extend(OWTileRegions[owid]) + exist_lw_regions.extend(OWTileRegions.inverse[owid]) for owid in dw_owids: - exist_dw_regions.extend(OWTileRegions[owid]) + exist_dw_regions.extend(OWTileRegions.inverse[owid]) tile_groups[(name,)] = (exist_owids, exist_lw_regions, exist_dw_regions) else: (exist_owids, exist_lw_regions, exist_dw_regions) = tile_groups[(name, groupType)] exist_owids.extend(lw_owids) exist_owids.extend(dw_owids) for owid in lw_owids: - exist_lw_regions.extend(OWTileRegions[owid]) + exist_lw_regions.extend(OWTileRegions.inverse[owid]) for owid in dw_owids: - exist_dw_regions.extend(OWTileRegions[owid]) + exist_dw_regions.extend(OWTileRegions.inverse[owid]) tile_groups[(name, groupType)] = (exist_owids, exist_lw_regions, exist_dw_regions) #tile shuffle happens here, the groups that remain in the list are the tiles that get swapped From a13975e4ff212732dc08939d16917475a0230c46 Mon Sep 17 00:00:00 2001 From: codemann8 Date: Sun, 18 Jul 2021 06:07:27 -0500 Subject: [PATCH 2/4] Implemented smarter Balanced Flute Shuffle --- OverworldShuffle.py | 115 +++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 49 deletions(-) diff --git a/OverworldShuffle.py b/OverworldShuffle.py index e710b917..841a5638 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -143,55 +143,6 @@ def link_overworld(world, player): region = world.get_region(name, player) region.type = RegionType.LightWorld - # flute shuffle - def connect_flutes(flute_destinations): - for o in range(0, len(flute_destinations)): - owslot = flute_destinations[o] - regions = flute_data[owslot][0] - if (world.mode[player] == 'inverted') == (flute_data[owslot][1] in world.owswaps[player][0] and world.owSwap[player] == 'mixed'): - connect_simple(world, 'Flute Spot ' + str(o + 1), regions[0], player) - else: - connect_simple(world, 'Flute Spot ' + str(o + 1), regions[1], player) - - if world.owFluteShuffle[player] == 'vanilla': - connect_flutes(default_flute_connections) - else: - flute_pool = list(flute_data.keys()) - new_spots = list() - - # guarantee desert/mire access - flute_pool.remove(0x38) - new_spots.append(0x38) - # guarantee mountain access - mountainIds = [0x0b, 0x0e, 0x07] - owslot = mountainIds[random.randint(0, 2)] - flute_pool.remove(owslot) - new_spots.append(owslot) - - random.shuffle(flute_pool) - f = 0 - while len(new_spots) < 8: - if f >= len(flute_pool): - f = 0 - if world.owFluteShuffle[player] == 'balanced': - if (flute_pool[f] + 1 in new_spots \ - or flute_pool[f] - 1 in new_spots \ - or flute_pool[f] + 8 in new_spots \ - or flute_pool[f] - 8 in new_spots) \ - or (random.randint(0, 31) != 0 \ - and (flute_pool[f] + 7 in new_spots - or flute_pool[f] - 7 in new_spots - or flute_pool[f] + 9 in new_spots - or flute_pool[f] - 9 in new_spots)): - f += 1 - continue - if flute_pool[f] not in new_spots: - new_spots.append(flute_pool[f]) - f += 1 - new_spots.sort() - world.owflutespots[player] = new_spots - connect_flutes(new_spots) - # make new connections for owid in ow_connections.keys(): if (world.mode[player] == 'inverted') == (owid in world.owswaps[player][0] and world.owSwap[player] == 'mixed'): @@ -260,6 +211,72 @@ def link_overworld(world, player): raise KeyError('No parallel edge for edge %d' % back_edge) assert len(connected_edges) == len(default_connections) * 2, connected_edges + + # flute shuffle + def connect_flutes(flute_destinations): + for o in range(0, len(flute_destinations)): + owslot = flute_destinations[o] + regions = flute_data[owslot][0] + if (world.mode[player] == 'inverted') == (flute_data[owslot][1] in world.owswaps[player][0] and world.owSwap[player] == 'mixed'): + connect_simple(world, 'Flute Spot ' + str(o + 1), regions[0], player) + else: + connect_simple(world, 'Flute Spot ' + str(o + 1), regions[1], player) + + if world.owFluteShuffle[player] == 'vanilla': + connect_flutes(default_flute_connections) + else: + flute_pool = list(flute_data.keys()) + new_spots = list() + ignored_regions = set() + + def addSpot(owid, removeFromPool = False): + if world.owFluteShuffle[player] == 'balanced': + def getIgnored(regionname, base_owid, owid): + region = world.get_region(regionname, player) + for exit in region.exits: + if exit.connected_region is not None and exit.connected_region.type in [RegionType.LightWorld, RegionType.DarkWorld] and exit.connected_region.name not in new_ignored: + if OWTileRegions[exit.connected_region.name] in [base_owid, owid] or OWTileRegions[regionname] == base_owid: + new_ignored.add(exit.connected_region.name) + getIgnored(exit.connected_region.name, base_owid, OWTileRegions[exit.connected_region.name]) + + if (world.mode[player] == 'inverted') == (flute_data[owid][1] in world.owswaps[player][0] and world.owSwap[player] == 'mixed'): + new_region = flute_data[owid][0][0] + else: + new_region = flute_data[owid][0][1] + + if new_region in ignored_regions: + return False + + new_ignored = {new_region} + getIgnored(new_region, OWTileRegions[new_region], OWTileRegions[new_region]) + if random.randint(0, 31) != 0 and new_ignored.intersection(ignored_regions): + return False + ignored_regions.update(new_ignored) + if removeFromPool: + flute_pool.remove(owid) + new_spots.append(owid) + return True + + # guarantee desert/mire access + addSpot(0x38, True) + + # guarantee mountain access + if world.owShuffle[player] == 'vanilla': + mountainIds = [0x0b, 0x0e, 0x07] + addSpot(mountainIds[random.randint(0, 2)], True) + + random.shuffle(flute_pool) + f = 0 + while len(new_spots) < 8: + if f >= len(flute_pool): + f = 0 + if flute_pool[f] not in new_spots: + addSpot(flute_pool[f]) + f += 1 + new_spots.sort() + world.owflutespots[player] = new_spots + connect_flutes(new_spots) + def connect_custom(world, connected_edges, player): if hasattr(world, 'custom_overworld') and world.custom_overworld[player]: From 36f60c78b00f685ee6114a89cb9f85b3bd4e0c27 Mon Sep 17 00:00:00 2001 From: codemann8 Date: Sun, 18 Jul 2021 06:08:02 -0500 Subject: [PATCH 3/4] Fixed incorrect Collection Rate in credits --- Rom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rom.py b/Rom.py index 8dcf902e..ae6b4114 100644 --- a/Rom.py +++ b/Rom.py @@ -894,7 +894,7 @@ def patch_rom(world, rom, player, team, enemized, is_mystery=False): write_int16(rom, 0x187010, credits_total) # dynamic credits if credits_total != 216: # collection rate address: - cr_address = 0x2391C4 + cr_address = 0x2391C2 cr_pc = cr_address - 0x120000 # convert to pc mid_top, mid_bot = credits_digit((credits_total // 10) % 10) last_top, last_bot = credits_digit(credits_total % 10) From 4c1412f2deb755601960b7f05002a3226e6956ce Mon Sep 17 00:00:00 2001 From: codemann8 Date: Sun, 18 Jul 2021 06:10:27 -0500 Subject: [PATCH 4/4] Version bump 0.1.6.8 --- CHANGELOG.md | 6 +++++- OverworldShuffle.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 455a22d2..8f37542f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +### 0.1.6.8 +- Implemented a smarter Balanced Flute Shuffle algorithm +- Fixed Collection Rate in credits +- Removed sortedcontainers dependency + ### 0.1.6.7 - Mountain Entry and West Death Mountain are now Swapped independently (Old Man rescue is always in your starting world) - Fixed issue with AT/GT access logic @@ -7,7 +12,6 @@ - Fixed Boss Music when boss room is entered thru straight stairs - Suppressed in-dungeon music changes when DR is enabled - Fixed issue with Pyramid Exit exiting to wrong location in ER -- Removed sortedcontainers dependency - ~~Merged DR v0.4.0.11 - Various DR changes~~ ### 0.1.6.6 diff --git a/OverworldShuffle.py b/OverworldShuffle.py index 841a5638..accba4a3 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -2,7 +2,7 @@ import random, logging, copy from BaseClasses import OWEdge, WorldType, RegionType, Direction, Terrain, PolSlot from OWEdges import OWTileRegions, OWTileGroups, OWEdgeGroups, OpenStd, parallel_links, IsParallel -__version__ = '0.1.6.7-u' +__version__ = '0.1.6.8-u' def link_overworld(world, player): # setup mandatory connections