Core: "Fix" Priority Fill (#3592)
* Priority fill -> Don't use one item per player * fix unit test thing * Ok, I think this should do it properly
This commit is contained in:
		
							parent
							
								
									72e88bb493
								
							
						
					
					
						commit
						7adb673a80
					
				
							
								
								
									
										20
									
								
								Fill.py
								
								
								
								
							
							
						
						
									
										20
									
								
								Fill.py
								
								
								
								
							| 
						 | 
				
			
			@ -36,7 +36,8 @@ def sweep_from_pool(base_state: CollectionState, itempool: typing.Sequence[Item]
 | 
			
		|||
def fill_restrictive(multiworld: MultiWorld, base_state: CollectionState, locations: typing.List[Location],
 | 
			
		||||
                     item_pool: typing.List[Item], single_player_placement: bool = False, lock: bool = False,
 | 
			
		||||
                     swap: bool = True, on_place: typing.Optional[typing.Callable[[Location], None]] = None,
 | 
			
		||||
                     allow_partial: bool = False, allow_excluded: bool = False, name: str = "Unknown") -> None:
 | 
			
		||||
                     allow_partial: bool = False, allow_excluded: bool = False, one_item_per_player: bool = True,
 | 
			
		||||
                     name: str = "Unknown") -> None:
 | 
			
		||||
    """
 | 
			
		||||
    :param multiworld: Multiworld to be filled.
 | 
			
		||||
    :param base_state: State assumed before fill.
 | 
			
		||||
| 
						 | 
				
			
			@ -63,14 +64,22 @@ def fill_restrictive(multiworld: MultiWorld, base_state: CollectionState, locati
 | 
			
		|||
    placed = 0
 | 
			
		||||
 | 
			
		||||
    while any(reachable_items.values()) and locations:
 | 
			
		||||
        # grab one item per player
 | 
			
		||||
        items_to_place = [items.pop()
 | 
			
		||||
                          for items in reachable_items.values() if items]
 | 
			
		||||
        if one_item_per_player:
 | 
			
		||||
            # grab one item per player
 | 
			
		||||
            items_to_place = [items.pop()
 | 
			
		||||
                              for items in reachable_items.values() if items]
 | 
			
		||||
        else:
 | 
			
		||||
            next_player = multiworld.random.choice([player for player, items in reachable_items.items() if items])
 | 
			
		||||
            items_to_place = []
 | 
			
		||||
            if item_pool:
 | 
			
		||||
                items_to_place.append(reachable_items[next_player].pop())
 | 
			
		||||
 | 
			
		||||
        for item in items_to_place:
 | 
			
		||||
            for p, pool_item in enumerate(item_pool):
 | 
			
		||||
                if pool_item is item:
 | 
			
		||||
                    item_pool.pop(p)
 | 
			
		||||
                    break
 | 
			
		||||
 | 
			
		||||
        maximum_exploration_state = sweep_from_pool(
 | 
			
		||||
            base_state, item_pool + unplaced_items, multiworld.get_filled_locations(item.player)
 | 
			
		||||
            if single_player_placement else None)
 | 
			
		||||
| 
						 | 
				
			
			@ -480,7 +489,8 @@ def distribute_items_restrictive(multiworld: MultiWorld,
 | 
			
		|||
    if prioritylocations:
 | 
			
		||||
        # "priority fill"
 | 
			
		||||
        fill_restrictive(multiworld, multiworld.state, prioritylocations, progitempool,
 | 
			
		||||
                         single_player_placement=single_player, swap=False, on_place=mark_for_locking, name="Priority")
 | 
			
		||||
                         single_player_placement=single_player, swap=False, on_place=mark_for_locking,
 | 
			
		||||
                         name="Priority", one_item_per_player=False)
 | 
			
		||||
        accessibility_corrections(multiworld, multiworld.state, prioritylocations, progitempool)
 | 
			
		||||
        defaultlocations = prioritylocations + defaultlocations
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue