Simplify the only-beatable mode.
This also makes it faster.
This commit is contained in:
		
							parent
							
								
									5336e6c693
								
							
						
					
					
						commit
						17cd963665
					
				|  | @ -183,6 +183,13 @@ class World(object): | |||
|                 return True | ||||
| 
 | ||||
|         return False | ||||
|          | ||||
|     def has_beaten_game(self, state): | ||||
|         if state.has('Triforce'): return True | ||||
|         if self.goal in ['triforcehunt']: | ||||
|             if state.item_count('Triforce Piece')+state.item_count('Power Star')> self.treasure_hunt_count: | ||||
|                 return True | ||||
|         return False | ||||
| 
 | ||||
|     def can_beat_game(self, starting_state=None): | ||||
|         prog_locations = [location for location in self.get_locations() if location.item is not None and (location.item.advancement or location.event)] | ||||
|  | @ -317,7 +324,10 @@ class CollectionState(object): | |||
|         if count == 1: | ||||
|             return item in self.prog_items | ||||
|         else: | ||||
|             return len([pritem for pritem in self.prog_items if pritem == item]) >= count | ||||
|             return self.item_count(item) >= count | ||||
|      | ||||
|     def item_count(self, item): | ||||
|         return len([pritem for pritem in self.prog_items if pritem == item]) | ||||
| 
 | ||||
|     def can_lift_rocks(self): | ||||
|         return self.has('Power Glove') or self.has('Titans Mitts') | ||||
|  |  | |||
							
								
								
									
										17
									
								
								Fill.py
								
								
								
								
							
							
						
						
									
										17
									
								
								Fill.py
								
								
								
								
							|  | @ -167,23 +167,14 @@ def fill_restrictive(world, base_state, locations, itempool): | |||
|     while itempool and locations: | ||||
|         item_to_place = itempool.pop() | ||||
|         maximum_exploration_state = sweep_from_pool() | ||||
|          | ||||
|         if world.check_beatable_only: | ||||
|             can_beat_without = world.has_beaten_game(maximum_exploration_state) | ||||
| 
 | ||||
|         spot_to_fill = None | ||||
|         for location in locations: | ||||
|             if location.can_fill(item_to_place): | ||||
|                 if world.check_beatable_only: | ||||
|                     starting_state = base_state.copy() | ||||
|                     for item in itempool: | ||||
|                         starting_state.collect(item, True) | ||||
| 
 | ||||
|                 if maximum_exploration_state.can_reach(location): | ||||
|                     if world.check_beatable_only: | ||||
|                         starting_state.collect(item_to_place, True) | ||||
|                     else: | ||||
|                         spot_to_fill = location | ||||
|                         break | ||||
| 
 | ||||
|                 if world.check_beatable_only and world.can_beat_game(starting_state): | ||||
|                 if (world.check_beatable_only and can_beat_without) or maximum_exploration_state.can_reach(location): | ||||
|                     spot_to_fill = location | ||||
|                     break | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								Main.py
								
								
								
								
							
							
						
						
									
										2
									
								
								Main.py
								
								
								
								
							|  | @ -118,6 +118,7 @@ def generate_itempool(world): | |||
|         raise NotImplementedError('Not supported yet') | ||||
| 
 | ||||
|     world.push_item('Ganon', ItemFactory('Triforce'), False) | ||||
|     world.get_location('Ganon').event = True | ||||
|     world.push_item('Agahnim 1', ItemFactory('Beat Agahnim 1'), False) | ||||
|     world.get_location('Agahnim 1').event = True | ||||
|     world.push_item('Agahnim 2', ItemFactory('Beat Agahnim 2'), False) | ||||
|  | @ -177,6 +178,7 @@ def generate_itempool(world): | |||
| 
 | ||||
|     if world.goal == 'pedestal': | ||||
|         world.push_item('Master Sword Pedestal', ItemFactory('Triforce'), False) | ||||
|         world.get_location('Master Sword Pedestal').event = True | ||||
|     elif world.goal == 'triforcehunt': | ||||
|         world.treasure_hunt_count = 20 | ||||
|         world.treasure_hunt_icon = 'Triforce Piece' | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue