def test_calculate_reach_with_all_pickups(test_data): game, state, _ = test_data item_pool = calculate_item_pool(LayoutConfiguration.from_params(), game.resource_database, state.patches) add_resources_into_another(state.resources, item_pool[0].starting_items) for pickup in item_pool[1]: add_pickup_to_state(state, pickup) first_reach, second_reach = _create_reaches_and_compare(game, state) first_actions, second_actions = _compare_actions(first_reach, second_reach) found_pickups = set( filter_pickup_nodes(filter_reachable(second_reach.nodes, first_reach))) all_pickups = set(filter_pickup_nodes(game.world_list.all_nodes)) # assert (len(list(first_reach.nodes)), len(first_actions)) == (898, 9) # assert (len(list(second_reach.nodes)), len(second_actions)) == (898, 9) pprint.pprint(first_actions) assert all_pickups == found_pickups
def _retryable_create_patches( configuration: LayoutConfiguration, game: GameDescription, rng: Random, status_update: Callable[[str], None], ) -> Tuple[GamePatches, List[PickupEntry]]: """ Runs the rng-dependant parts of the generation, with retries :param configuration: :param game: :param rng: :param status_update: :return: """ base_patches = base_patches_factory.create_base_patches( configuration, rng, game) pool_patches, item_pool = pool_creator.calculate_item_pool( configuration, game.resource_database, base_patches) _validate_item_pool_size(item_pool, game) return run_filler(configuration, game, item_pool, pool_patches, rng, status_update)
def __init__(self, persistence_path: Path, layout_configuration: LayoutConfiguration): super().__init__() self.setupUi(self) set_default_window_icon(self) self.menu_reset_action = QAction("Reset", self) self.menu_reset_action.triggered.connect(self._confirm_reset) self.menu_bar.addAction(self.menu_reset_action) self._collected_pickups = {} self._widget_for_pickup = {} self._actions = [] self._asset_id_to_item = {} self._node_to_item = {} self.layout_configuration = layout_configuration self.persistence_path = persistence_path self.game_description = data_reader.decode_data( layout_configuration.game_data) try: base_patches = base_patches_factory.create_base_patches( self.layout_configuration, None, self.game_description) except base_patches_factory.MissingRng as e: raise InvalidLayoutForTracker( "Layout is configured to have random {}, " "but that isn't supported by the tracker.".format(e)) pool_patches, item_pool = pool_creator.calculate_item_pool( self.layout_configuration, self.game_description.resource_database, base_patches) self.game_description, self._initial_state = logic_bootstrap( layout_configuration, self.game_description, pool_patches) self.logic = Logic(self.game_description, layout_configuration) self._initial_state.resources[ "add_self_as_requirement_to_resources"] = 1 self.resource_filter_check.stateChanged.connect( self.update_locations_tree_for_reachable_nodes) self.hide_collected_resources_check.stateChanged.connect( self.update_locations_tree_for_reachable_nodes) self.undo_last_action_button.clicked.connect(self._undo_last_action) self.configuration_label.setText( "Trick Level: {}; Elevators: Vanilla; Starts with:\n{}".format( layout_configuration.trick_level_configuration.global_level. value, ", ".join(resource.short_name for resource in pool_patches.starting_items.keys()))) self.setup_pickups_box(item_pool) self.setup_possible_locations_tree() self._starting_nodes = { node for node in self.game_description.world_list.all_nodes if node.is_resource_node and node.resource() in self._initial_state.resources } persistence_path.mkdir(parents=True, exist_ok=True) previous_state = _load_previous_state(persistence_path, layout_configuration) if not self.apply_previous_state(previous_state): with persistence_path.joinpath("layout_configuration.json").open( "w") as layout_file: json.dump(layout_configuration.as_json, layout_file) self._add_new_action(self._initial_state.node)