some optimization
This commit is contained in:
parent
e7073153e1
commit
26ea2d5905
|
@ -738,16 +738,6 @@ class CollectionState(object):
|
||||||
self.reachable_regions[item.player] = set()
|
self.reachable_regions[item.player] = set()
|
||||||
self.stale[item.player] = True
|
self.stale[item.player] = True
|
||||||
|
|
||||||
def __getattr__(self, item):
|
|
||||||
if item.startswith('can_reach_'):
|
|
||||||
return self.can_reach(item[10])
|
|
||||||
#elif item.startswith('has_'):
|
|
||||||
# return self.has(item[4])
|
|
||||||
if item == '__len__':
|
|
||||||
return
|
|
||||||
|
|
||||||
raise RuntimeError('Cannot parse %s.' % item)
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class RegionType(Enum):
|
class RegionType(Enum):
|
||||||
LightWorld = 1
|
LightWorld = 1
|
||||||
|
|
9
Fill.py
9
Fill.py
|
@ -161,7 +161,7 @@ def distribute_items_staleness(world):
|
||||||
logging.getLogger('').debug('Unplaced items: %s - Unfilled Locations: %s', [item.name for item in itempool], [location.name for location in fill_locations])
|
logging.getLogger('').debug('Unplaced items: %s - Unfilled Locations: %s', [item.name for item in itempool], [location.name for location in fill_locations])
|
||||||
|
|
||||||
|
|
||||||
def fill_restrictive(world, base_state, locations, itempool, single_player_placement = False):
|
def fill_restrictive(world, base_state: CollectionState, locations, itempool, single_player_placement=False):
|
||||||
def sweep_from_pool():
|
def sweep_from_pool():
|
||||||
new_state = base_state.copy()
|
new_state = base_state.copy()
|
||||||
for item in itempool:
|
for item in itempool:
|
||||||
|
@ -190,7 +190,6 @@ def fill_restrictive(world, base_state, locations, itempool, single_player_place
|
||||||
perform_access_check = True
|
perform_access_check = True
|
||||||
if world.accessibility[item_to_place.player] == 'none':
|
if world.accessibility[item_to_place.player] == 'none':
|
||||||
perform_access_check = not world.has_beaten_game(maximum_exploration_state, item_to_place.player) if single_player_placement else not has_beaten_game
|
perform_access_check = not world.has_beaten_game(maximum_exploration_state, item_to_place.player) if single_player_placement else not has_beaten_game
|
||||||
|
|
||||||
for location in locations:
|
for location in locations:
|
||||||
if (not single_player_placement or location.player == item_to_place.player)\
|
if (not single_player_placement or location.player == item_to_place.player)\
|
||||||
and location.can_fill(maximum_exploration_state, item_to_place, perform_access_check):
|
and location.can_fill(maximum_exploration_state, item_to_place, perform_access_check):
|
||||||
|
@ -200,9 +199,9 @@ def fill_restrictive(world, base_state, locations, itempool, single_player_place
|
||||||
else:
|
else:
|
||||||
# we filled all reachable spots. Maybe the game can be beaten anyway?
|
# we filled all reachable spots. Maybe the game can be beaten anyway?
|
||||||
unplaced_items.insert(0, item_to_place)
|
unplaced_items.insert(0, item_to_place)
|
||||||
if world.can_beat_game():
|
if world.accessibility[item_to_place.player] != 'none' and world.can_beat_game():
|
||||||
if world.accessibility[item_to_place.player] != 'none':
|
logging.getLogger('').warning(
|
||||||
logging.getLogger('').warning('Not all items placed. Game beatable anyway. (Could not place %s)' % item_to_place)
|
'Not all items placed. Game beatable anyway. (Could not place %s)' % item_to_place)
|
||||||
continue
|
continue
|
||||||
raise FillError('No more spots to place %s' % item_to_place)
|
raise FillError('No more spots to place %s' % item_to_place)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue