Rain prevention fix for keydoors (plus test case)

Couple fixes for standard throne
This commit is contained in:
aerinon
2022-09-07 16:50:44 -06:00
parent 5850edfbe6
commit e2b9735600
5 changed files with 35 additions and 11 deletions

View File

@@ -16,6 +16,7 @@ from Dungeons import dungeon_regions, split_region_starts
from RoomData import DoorKind from RoomData import DoorKind
from source.dungeon.DungeonStitcher import generate_dungeon_find_proposal from source.dungeon.DungeonStitcher import generate_dungeon_find_proposal
from source.dungeon.DungeonStitcher import GenerationException as OtherGenException
class GraphPiece: class GraphPiece:
@@ -1505,6 +1506,8 @@ def calc_allowance_and_dead_ends(builder, connections_tuple, world, player):
builder.branches -= 1 builder.branches -= 1
if entrance not in drop_entrances_allowance: if entrance not in drop_entrances_allowance:
needed_connections.append(entrance) needed_connections.append(entrance)
if builder.sewers_access:
starting_allowance += 1
builder.allowance = starting_allowance builder.allowance = starting_allowance
for entrance in needed_connections: for entrance in needed_connections:
sector = find_sector(entrance, builder.sectors) sector = find_sector(entrance, builder.sectors)
@@ -3051,7 +3054,7 @@ def split_dungeon_builder(builder, split_list, builder_info):
comb_w_replace = len(dungeon_map) ** len(candidate_sectors) comb_w_replace = len(dungeon_map) ** len(candidate_sectors)
return balance_split(candidate_sectors, dungeon_map, global_pole, builder_info) return balance_split(candidate_sectors, dungeon_map, global_pole, builder_info)
except (GenerationException, NeutralizingException): except (GenerationException, NeutralizingException):
if comb_w_replace and comb_w_replace <= 10000: if comb_w_replace and comb_w_replace <= 10000 and not builder.throne_door:
attempts += 5 # all the combinations were tried already, no use repeating attempts += 5 # all the combinations were tried already, no use repeating
else: else:
attempts += 1 attempts += 1
@@ -3535,7 +3538,7 @@ def check_for_valid_layout(builder, sector_list, builder_info):
split_list['Sewers'].remove(temp_builder.throne_door.entrance.parent_region.name) split_list['Sewers'].remove(temp_builder.throne_door.entrance.parent_region.name)
builder.exception_list = list(sector_list) builder.exception_list = list(sector_list)
return True, {}, package return True, {}, package
except (GenerationException, NeutralizingException): except (GenerationException, NeutralizingException, OtherGenException):
builder.split_dungeon_map = None builder.split_dungeon_map = None
builder.valid_proposal = None builder.valid_proposal = None
if temp_builder.name == 'Hyrule Castle' and temp_builder.throne_door: if temp_builder.name == 'Hyrule Castle' and temp_builder.throne_door:
@@ -3948,20 +3951,20 @@ def find_free_equation(equations):
def copy_door_equations(builder, sector_list): def copy_door_equations(builder, sector_list):
equations = {} equations = {}
for sector in builder.sectors + sector_list: for sector in builder.sectors + sector_list:
sector.equations = calc_sector_equations(sector) sector.equations = calc_sector_equations(sector, builder.sewers_access)
curr_list = equations[sector] = [] curr_list = equations[sector] = []
for equation in sector.equations: for equation in sector.equations:
curr_list.append(equation.copy()) curr_list.append(equation.copy())
return equations return equations
def calc_sector_equations(sector): def calc_sector_equations(sector, sewers_flag=False):
equations = [] equations = []
is_entrance = sector.is_entrance_sector() and not sector.destination_entrance is_entrance = (sector.is_entrance_sector() and not sector.destination_entrance) or sewers_flag
if is_entrance: if is_entrance:
flagged_equations = [] flagged_equations = []
for door in sector.outstanding_doors: for door in sector.outstanding_doors:
equation, flag = calc_door_equation(door, sector, True) equation, flag = calc_door_equation(door, sector, True, sewers_flag)
if flag: if flag:
flagged_equations.append(equation) flagged_equations.append(equation)
equations.append(equation) equations.append(equation)
@@ -3977,9 +3980,9 @@ def calc_sector_equations(sector):
return equations return equations
def calc_door_equation(door, sector, look_for_entrance): def calc_door_equation(door, sector, look_for_entrance, sewers_flag=None):
if look_for_entrance and not door.blocked: if look_for_entrance and not door.blocked:
flag = sector.is_entrance_sector() flag = sector.is_entrance_sector() or sewers_flag
if flag: if flag:
eq = DoorEquation(door) eq = DoorEquation(door)
eq.benefit[hook_from_door(door)].append(door) eq.benefit[hook_from_door(door)].append(door)

2
Rom.py
View File

@@ -37,7 +37,7 @@ from source.dungeon.RoomList import Room0127
JAP10HASH = '03a63945398191337e896e5771f77173' JAP10HASH = '03a63945398191337e896e5771f77173'
RANDOMIZERBASEHASH = '0be31dc5cb338e7e85d1ce65e839c99e' RANDOMIZERBASEHASH = '61c296effe6180274721d570d2471e1c'
class JsonRom(object): class JsonRom(object):

Binary file not shown.

View File

@@ -56,6 +56,8 @@ def generate_dungeon_find_proposal(builder, entrance_region_names, split_dungeon
if (access_region.name in world.inaccessible_regions[player] and if (access_region.name in world.inaccessible_regions[player] and
region.name not in world.enabled_entrances[player]): region.name not in world.enabled_entrances[player]):
excluded[region] = None excluded[region] = None
elif split_dungeon and builder.sewers_access and builder.sewers_access.entrance.parent_region == region:
continue
elif len(region.entrances) == 1: # for holes elif len(region.entrances) == 1: # for holes
access_region = next(x.parent_region for x in region.entrances access_region = next(x.parent_region for x in region.entrances
if x.parent_region.type in [RegionType.LightWorld, RegionType.DarkWorld] if x.parent_region.type in [RegionType.LightWorld, RegionType.DarkWorld]
@@ -182,11 +184,17 @@ def modify_proposal(proposed_map, explored_state, doors_to_connect, hash_code_se
return proposed_map, hash_code return proposed_map, hash_code
attempt, opp_hook = None, None attempt, opp_hook = None, None
opp_hook_len = 0 opp_hook_len, possible_swaps = 0, list(visited_choices)
while opp_hook_len == 0: while opp_hook_len == 0:
attempt = random.choice(visited_choices) if len(possible_swaps) == 0:
break
attempt = random.choice(possible_swaps)
possible_swaps.remove(attempt)
opp_hook = type_map[hook_from_door(attempt)] opp_hook = type_map[hook_from_door(attempt)]
opp_hook_len = len(unvisted_bucket[opp_hook]) opp_hook_len = len(unvisted_bucket[opp_hook])
if opp_hook_len == 0:
itr += 1
continue
unvisted_bucket[opp_hook].sort(key=lambda d: d.name) unvisted_bucket[opp_hook].sort(key=lambda d: d.name)
new_door = random.choice(unvisted_bucket[opp_hook]) new_door = random.choice(unvisted_bucket[opp_hook])
old_target = proposed_map[attempt] old_target = proposed_map[attempt]

View File

@@ -0,0 +1,13 @@
meta:
players: 1
settings:
1:
door_shuffle: crossed
mode: standard
shuffle: crossed
doors:
1:
doors:
Hyrule Castle East Lobby N:
dest: Sewers Secret Room Key Door S
type: Key Door