fix(generation): reduce memory usage for bunny walk calculations

fix(key logic): make partial the default
This commit is contained in:
aerinon
2023-12-28 17:22:36 -07:00
parent 81e5aff923
commit 337ace1fa3
4 changed files with 9 additions and 4 deletions

View File

@@ -148,7 +148,7 @@ class World(object):
set_player_attr('door_self_loops', False) set_player_attr('door_self_loops', False)
set_player_attr('door_type_mode', 'original') set_player_attr('door_type_mode', 'original')
set_player_attr('trap_door_mode', 'optional') set_player_attr('trap_door_mode', 'optional')
set_player_attr('key_logic_algorithm', 'default') set_player_attr('key_logic_algorithm', 'partial')
set_player_attr('aga_randomness', True) set_player_attr('aga_randomness', True)
set_player_attr('shopsanity', False) set_player_attr('shopsanity', False)

2
CLI.py
View File

@@ -216,7 +216,7 @@ def parse_settings():
'intensity': 2, 'intensity': 2,
'door_type_mode': 'original', 'door_type_mode': 'original',
'trap_door_mode': 'optional', 'trap_door_mode': 'optional',
'key_logic_algorithm': 'default', 'key_logic_algorithm': 'partial',
'decoupledoors': False, 'decoupledoors': False,
'door_self_loops': False, 'door_self_loops': False,
'experimental': False, 'experimental': False,

View File

@@ -143,6 +143,8 @@ These are now independent of retro mode and have three options: None, Random, an
* 1.4.0.0v * 1.4.0.0v
* Initial support for HMG (Thanks Muffins!) * Initial support for HMG (Thanks Muffins!)
* Generation: fix for bunny walk logic taking up too much memory
* Key Logic: Partial is now the new default
* Enemizer: enemy bans * Enemizer: enemy bans
* 1.3.0.9v * 1.3.0.9v
* ER: New Swapped ER mode borrowed from OWR * ER: New Swapped ER mode borrowed from OWR

View File

@@ -1945,14 +1945,16 @@ def set_bunny_rules(world, player, inverted):
# a) being able to reach it, and # a) being able to reach it, and
# b) being able to access all entrances from there to `region` # b) being able to access all entrances from there to `region`
queue = deque([(region, [], {region})]) queue = deque([(region, [], {region})])
seen_sets = set([frozenset({region})])
while queue: while queue:
(current, path, seen) = queue.popleft() (current, path, seen) = queue.popleft()
for entrance in current.entrances: for entrance in current.entrances:
new_region = entrance.parent_region new_region = entrance.parent_region
if new_region.type in (RegionType.Cave, RegionType.Dungeon) and new_region in seen: new_seen = seen.union({new_region})
if new_region.type in (RegionType.Cave, RegionType.Dungeon) and new_seen in seen_sets:
continue continue
new_path = path + [entrance.access_rule] new_path = path + [entrance.access_rule]
new_seen = seen.union({new_region}) seen_sets.add(frozenset(new_seen))
if not is_link(new_region): if not is_link(new_region):
if world.logic[player] in ['owglitches', 'hybridglitches']: if world.logic[player] in ['owglitches', 'hybridglitches']:
if region.type == RegionType.Dungeon and new_region.type != RegionType.Dungeon: if region.type == RegionType.Dungeon and new_region.type != RegionType.Dungeon:
@@ -1997,6 +1999,7 @@ def set_bunny_rules(world, player, inverted):
else: else:
continue continue
if is_bunny(new_region): if is_bunny(new_region):
# todo: if not owg or hmg and entrance is in bunny_impassible_doors, then skip this nonsense?
queue.append((new_region, new_path, new_seen)) queue.append((new_region, new_path, new_seen))
else: else:
# we have reached pure light world, so we have a new possible option # we have reached pure light world, so we have a new possible option