Core: dump all item placements for generation failures. (#3237)
* Core: dump all item placements for generation failures * pass the multiworld from remaining fill * change how the args get handled to fix formatting --------- Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
parent
96d48a923a
commit
8e7ea06f39
19
Fill.py
19
Fill.py
|
@ -12,7 +12,12 @@ from worlds.generic.Rules import add_item_rule
|
||||||
|
|
||||||
|
|
||||||
class FillError(RuntimeError):
|
class FillError(RuntimeError):
|
||||||
pass
|
def __init__(self, *args: typing.Union[str, typing.Any], **kwargs) -> None:
|
||||||
|
if "multiworld" in kwargs and isinstance(args[0], str):
|
||||||
|
placements = (args[0] + f"\nAll Placements:\n" +
|
||||||
|
f"{[(loc, loc.item) for loc in kwargs['multiworld'].get_filled_locations()]}")
|
||||||
|
args = (placements, *args[1:])
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
def _log_fill_progress(name: str, placed: int, total_items: int) -> None:
|
def _log_fill_progress(name: str, placed: int, total_items: int) -> None:
|
||||||
|
@ -212,7 +217,7 @@ def fill_restrictive(multiworld: MultiWorld, base_state: CollectionState, locati
|
||||||
f"Unfilled locations:\n"
|
f"Unfilled locations:\n"
|
||||||
f"{', '.join(str(location) for location in locations)}\n"
|
f"{', '.join(str(location) for location in locations)}\n"
|
||||||
f"Already placed {len(placements)}:\n"
|
f"Already placed {len(placements)}:\n"
|
||||||
f"{', '.join(str(place) for place in placements)}")
|
f"{', '.join(str(place) for place in placements)}", multiworld=multiworld)
|
||||||
|
|
||||||
item_pool.extend(unplaced_items)
|
item_pool.extend(unplaced_items)
|
||||||
|
|
||||||
|
@ -299,7 +304,7 @@ def remaining_fill(multiworld: MultiWorld,
|
||||||
f"Unfilled locations:\n"
|
f"Unfilled locations:\n"
|
||||||
f"{', '.join(str(location) for location in locations)}\n"
|
f"{', '.join(str(location) for location in locations)}\n"
|
||||||
f"Already placed {len(placements)}:\n"
|
f"Already placed {len(placements)}:\n"
|
||||||
f"{', '.join(str(place) for place in placements)}")
|
f"{', '.join(str(place) for place in placements)}", multiworld=multiworld)
|
||||||
|
|
||||||
itempool.extend(unplaced_items)
|
itempool.extend(unplaced_items)
|
||||||
|
|
||||||
|
@ -506,7 +511,8 @@ def distribute_items_restrictive(multiworld: MultiWorld,
|
||||||
if progitempool:
|
if progitempool:
|
||||||
raise FillError(
|
raise FillError(
|
||||||
f"Not enough locations for progression items. "
|
f"Not enough locations for progression items. "
|
||||||
f"There are {len(progitempool)} more progression items than there are available locations."
|
f"There are {len(progitempool)} more progression items than there are available locations.",
|
||||||
|
multiworld=multiworld,
|
||||||
)
|
)
|
||||||
accessibility_corrections(multiworld, multiworld.state, defaultlocations)
|
accessibility_corrections(multiworld, multiworld.state, defaultlocations)
|
||||||
|
|
||||||
|
@ -523,7 +529,8 @@ def distribute_items_restrictive(multiworld: MultiWorld,
|
||||||
if excludedlocations:
|
if excludedlocations:
|
||||||
raise FillError(
|
raise FillError(
|
||||||
f"Not enough filler items for excluded locations. "
|
f"Not enough filler items for excluded locations. "
|
||||||
f"There are {len(excludedlocations)} more excluded locations than filler or trap items."
|
f"There are {len(excludedlocations)} more excluded locations than filler or trap items.",
|
||||||
|
multiworld=multiworld,
|
||||||
)
|
)
|
||||||
|
|
||||||
restitempool = filleritempool + usefulitempool
|
restitempool = filleritempool + usefulitempool
|
||||||
|
@ -589,7 +596,7 @@ def flood_items(multiworld: MultiWorld) -> None:
|
||||||
if candidate_item_to_place is not None:
|
if candidate_item_to_place is not None:
|
||||||
item_to_place = candidate_item_to_place
|
item_to_place = candidate_item_to_place
|
||||||
else:
|
else:
|
||||||
raise FillError('No more progress items left to place.')
|
raise FillError('No more progress items left to place.', multiworld=multiworld)
|
||||||
|
|
||||||
# find item to replace with progress item
|
# find item to replace with progress item
|
||||||
location_list = multiworld.get_reachable_locations()
|
location_list = multiworld.get_reachable_locations()
|
||||||
|
|
5
Main.py
5
Main.py
|
@ -11,7 +11,8 @@ from typing import Dict, List, Optional, Set, Tuple, Union
|
||||||
|
|
||||||
import worlds
|
import worlds
|
||||||
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld, Region
|
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld, Region
|
||||||
from Fill import balance_multiworld_progression, distribute_items_restrictive, distribute_planned, flood_items
|
from Fill import FillError, balance_multiworld_progression, distribute_items_restrictive, distribute_planned, \
|
||||||
|
flood_items
|
||||||
from Options import StartInventoryPool
|
from Options import StartInventoryPool
|
||||||
from Utils import __version__, output_path, version_tuple, get_settings
|
from Utils import __version__, output_path, version_tuple, get_settings
|
||||||
from settings import get_settings
|
from settings import get_settings
|
||||||
|
@ -346,7 +347,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
output_file_futures.append(pool.submit(write_multidata))
|
output_file_futures.append(pool.submit(write_multidata))
|
||||||
if not check_accessibility_task.result():
|
if not check_accessibility_task.result():
|
||||||
if not multiworld.can_beat_game():
|
if not multiworld.can_beat_game():
|
||||||
raise Exception("Game appears as unbeatable. Aborting.")
|
raise FillError("Game appears as unbeatable. Aborting.", multiworld=multiworld)
|
||||||
else:
|
else:
|
||||||
logger.warning("Location Accessibility requirements not fulfilled.")
|
logger.warning("Location Accessibility requirements not fulfilled.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue